Akshay Khot has Published 41 Articles

How does the event pattern work in .NET?

Akshay Khot

Akshay Khot

Updated on 19-May-2021 08:05:42

398 Views

Events are a simplified pattern that uses delegates. In C#, all delegates have the multicast capability, i.e., an instance of a delegate can represent not just a single method but a list of methods. For example −Exampledelegate int Transformer(int x); static void Main(){    Transformer perform = x =>{   ... Read More

How do arrays work in C#?

Akshay Khot

Akshay Khot

Updated on 19-May-2021 07:51:18

151 Views

An array represents a fixed number of elements of a given type. The elements are stored in a contiguous block of memory and provide highly efficient access to the elements as long as you know the index of an element.The C# syntax to declare and initialize an array is as ... Read More

Explain the difference between const and readonly keywords in C#

Akshay Khot

Akshay Khot

Updated on 19-May-2021 07:50:10

569 Views

In C#, both the const and readonly keywords are used to define immutable values which cannot be modified once they are declared. However, there are some important differences between the two.constThe const modifier declares the constant values that are known at compile-time and do not change, i.e. they are immutable. ... Read More

What operators C# provides to deal with null values?

Akshay Khot

Akshay Khot

Updated on 19-May-2021 07:49:08

300 Views

C# has the following three operators to deal with the null values −null-coalescing operator (??)Allows you to get the value of a variable if it's not null, alternatively specifying a default value that can be used.It replaces the following expression in C# −string resultOne = value != null ? value ... Read More

How do interfaces work in C#?

Akshay Khot

Akshay Khot

Updated on 19-May-2021 07:47:44

422 Views

An interface defines a contract that will be implemented by a class or a struct. It can contain methods, properties, events, and indexers. An interface is similar to a class except that it doesn't hold any data and only specifies the behavior it can do (or more accurately, the class ... Read More

Explain the concept of delegates in C#

Akshay Khot

Akshay Khot

Updated on 19-May-2021 07:46:54

224 Views

If you are a C programmer, then delegates can be thought of as pointers to the function. However, delegates in C# are much more than a simple function pointer. This article explains the concept of delegates and their uses in day-to-day programming.Essentially, delegates provide a level of indirection. They encapsulate ... Read More

Explain how generics work in C#

Akshay Khot

Akshay Khot

Updated on 19-May-2021 07:46:04

310 Views

Generics were added in version 2.0 of C# and are among the most important concepts in the language. They enable you to write reusable, high-performance code that is type-safe at compile time. Using generics, you can use a type in your code without knowing about it beforehand.Generics are used in ... Read More

What is the usage of ref, out, and in keywords in C#?

Akshay Khot

Akshay Khot

Updated on 19-May-2021 07:41:00

362 Views

In C#, most of the methods can have zero or more parameters which define the data that must be provided to the method. Any code that calls the method has to pass the data (called arguments) to the method. A method declares its inputs as parameters, and they're provided by ... Read More

Provide a brief overview of the C# and .NET ecosystem

Akshay Khot

Akshay Khot

Updated on 19-May-2021 07:40:00

439 Views

C# is an object-oriented, type-safe and general-purpose programming language, which focuses on making the programmers productive. It tries to achieve this productivity through expressiveness, simplicity and a focus on performance. It works on different platforms such as Windows, Mac, and Linux.Type-SafetyC# is a statically typed language. That means the types ... Read More

Explain and contrast value types and reference types in C#

Akshay Khot

Akshay Khot

Updated on 19-May-2021 07:33:11

215 Views

In general, all types in C# can be divided into two main categories − value types and reference types. Let's look at each type in detail.Value TypesVariables of value types directly contain their data. Each variable has its own copy of the data. Hence it is impossible for a variable ... Read More

Advertisements