Discuss what garbage collection is and how it works. Provide a code example of how you can enforce garbage collection in .NET.

Garbage collection is a low-priority process that serves as an automatic memory manager which manages the allocation and release of memory for the applications. Each time a new object is created, the common language runtime allocates memory for that object from the managed Heap. As long as free memory space is available in the managed … Read more

Explain what LINQ is.

LINQ is an acronym for Language Integrated Query, and was introduced with Visual Studio 2008. LINQ is a set of features that extends query capabilities to the .NET language syntax by adding sets of new standard query operators that allow data manipulation, regardless of the data source. Supported data sources are: .NET Framework collections, SQL … Read more

Discuss the difference between constants and read-only variables.

While constants and read-only variable share many similarities, there are some important differences: Constants are evaluated at compile time, while the read-only variables are evaluated at run time. Constants support only value-type variables (the only exception being strings), while read-only variables can hold reference- type variables. Constants should be used when the value is not … Read more

Explain the difference between boxing and unboxing. Provide an example

Boxing is the process of converting a value type to the type object, and unboxing is extracting the value type from the object. While the boxing is implicit, unboxing is explicit. Example (written in C#): int i = 13; object myObject = i; // boxing i = (int)myObject; // unboxing In .NET interviews, explaining the … Read more

Explain the difference between the while and for loop. Provide a .NET syntax for both loops.

Both loops are used when a unit of code needs to execute repeatedly. The difference is that the for loop is used when you know how many times you need to iterate through the code. On the other hand, the while loop is used when you need to repeat something until a given statement is … Read more