C# Interview Questions 2026

C# interviews at Microsoft, enterprise software companies, and game studios (Unity) focus on LINQ, the async programming model, and CLR internals.

LINQ and Deferred Execution

LINQ queries are lazily evaluated: the query is not executed until you iterate over it (foreach, ToList(), Count()). This enables composition of operations without intermediate allocations.

Common mistake: calling ToList() too early, defeating deferred execution, or calling it too late on a query that hits the database multiple times. Understand when materialization is needed. Know the difference between IQueryable (SQL translation) and IEnumerable (in-memory).

async/await and the Task Pattern

async/await is syntactic sugar over Task-based Async Pattern (TAP). The await keyword suspends the method without blocking the thread. The continuation runs when the awaited task completes, typically on the original synchronization context.

Avoid async void except for event handlers (exceptions are unobservable). Use Task.WhenAll for parallel async operations. ConfigureAwait(false) avoids capturing the synchronization context in library code, preventing deadlocks in ASP.NET contexts.

Generics and Constraints

Generic constraints: where T : class, where T : struct, where T : new(), where T : SomeInterface. Covariance (out T) and contravariance (in T) on generic interfaces enable type-safe assignment compatibility.

Generic type inference: the compiler infers type arguments from method arguments. IEnumerable<T> is covariant, so you can assign IEnumerable<string> to IEnumerable<object>. IList<T> is invariant.

CLR Memory and Garbage Collection

The CLR garbage collector is generational: Generation 0 (short-lived objects), Generation 1 (medium), Generation 2 (long-lived). Large Object Heap (LOH) for objects >= 85KB; LOH is collected infrequently and not compacted by default.

Value types (structs) are allocated on the stack when they are local variables; boxed when assigned to an object reference. Boxing/unboxing incurs allocation. Avoid boxing in hot paths by using generic collections rather than non-generic ArrayList.

Browse C# and .NET Interview Questions

Real engineering questions from Microsoft and enterprise tech companies.

Browse Microsoft Questions