C# Interview Questions and Answers
The .NET runtime, LINQ, async/await, generics and object-oriented design.
Whether you are preparing for entry-level C# interview questions for freshers or senior software engineer interview questions addressing concurrency, scalability, and system architecture, this track provides peer-reviewed model answers with syntax walkthroughs, edge cases, and practical interview tips.
1 How does the .NET garbage collector work, including generations and the LOH? Hard
.NET uses a generational, compacting, tracing collector. New objects go to generation 0. Survivors are promoted to gen 1 then gen 2. Gen 0 collections are frequent and cheap because most objects die young; gen 2 collections are expensive and mark the whole heap.
Large objects of 85KB or more, such as big arrays, go to the Large Object Heap. It is not compacted by default to avoid moving costs, so it can fragment. ArrayPool<T> avoids repeated large allocations.
var buffer = ArrayPool<byte>.Shared.Rent(1_000_000);
try {
// use buffer
} finally {
ArrayPool<byte>.Shared.Return(buffer);
}
The GC is non-deterministic, so it does not replace IDisposable. Reduce pressure with pooling, Span<T> and structs, and measure with dotnet-counters or GC ETW events before optimising.
2 What causes async deadlocks and how does ConfigureAwait help? Hard
A classic deadlock happens in UI applications and classic ASP.NET when you block synchronously on async code with .Result or .Wait().
The awaited task wants to resume on the captured synchronisation context, but that context's single thread is blocked waiting for the task, so neither can proceed.
var data = GetDataAsync().Result; // deadlock in a UI/ASP.NET context
Fixes: go async all the way up and return Task instead of blocking, or use ConfigureAwait(false) in library code so continuations do not require the original context. ASP.NET Core has no synchronisation context, so this exact deadlock is less common there, but blocking still wastes threads and can starve the pool.
Other pitfalls include async void, unobserved task exceptions and not passing CancellationToken. Use Task.WhenAll for concurrency and IAsyncEnumerable<T> for asynchronous streams.
Frequently Asked Questions About C# Interviews
What do hiring managers evaluate in C# technical rounds?
Technical interviewers look for foundational fluency, idiomatic syntax, clarity when communicating complex logic, and awareness of performance trade-offs (e.g. memory footprint, render performance, and network latency) in production environments.
What are the best interview tips for practicing C# questions?
Use active recall: summarize each answer in your own words before revealing the model solution. Focus on explaining why a certain approach is chosen rather than just memorizing code syntax.