C# Interview Questions
The CLR & .NET, value vs reference types, delegates & events, LINQ, async/await, generics, records, pattern matching, garbage collection and DI.
61 questions
Popular Searches
1. What is C# and how does it relate to the .NET runtime and CLR?
easyLanguage Fundamentals 6 mins2. What is the difference between a value type and a reference type in C#?
mediumType System 6 mins3. What is the difference between a class and a struct in C#?
mediumType System 6 mins4. What are the boxing and unboxing operations in C# and why do they matter?
mediumType System 6 mins5. What is the difference between managed and unmanaged code in C#?
mediumRuntime 6 mins6. How does garbage collection work in C# and what are its generations?
hardMemory Management 7 mins7. What is the IDisposable interface and the using statement in C#?
mediumResource Management 7 mins8. What is the difference between const, readonly, and static in C#?
mediumFields and Modifiers 7 mins9. What are properties in C# and how do they differ from fields?
easyObject-Oriented Programming 6 mins10. What is the difference between an abstract class and an interface in C#?
mediumOOP 7 mins11. What are delegates in C# and how do they enable callbacks?
mediumDelegates 7 mins12. What is the difference between an event and a delegate in C#?
mediumEvents 7 mins13. What are lambda expressions and how do they relate to delegates in C#?
mediumLanguage Features 6 mins14. What is LINQ in C# and how does deferred execution work?
mediumLINQ 6 mins15. What is the difference between IEnumerable and IQueryable in C#?
hardCollections 7 mins16. What is async/await in C# and how does the Task-based model work?
mediumAsynchronous Programming 7 mins17. What is the difference between Task and Thread in C#?
mediumConcurrency 7 mins18. What are generics in C# and what problems do they solve?
mediumType System 7 mins19. What is the difference between ref, out, and in parameters in C#?
mediumMethod Parameters 6 mins20. What are extension methods in C# and how do they work?
mediumLanguage Features 6 mins21. What is the difference between == and .Equals() in C#?
mediumEquality 6 mins22. What are nullable reference types in C# and why were they introduced?
mediumType System 7 mins23. What is the difference between String and StringBuilder in C#?
easyStrings 6 mins24. What are records in C# and how do they differ from classes?
mediumTypes 7 mins25. What is pattern matching in C# and how has it evolved?
mediumLanguage Features 6 mins26. What is the difference between throw and throw ex in C# exception handling?
mediumException Handling 6 mins27. What are indexers in C# and when should you use them?
mediumObject-Oriented Programming 6 mins28. What is the difference between covariance and contravariance in C# generics?
hardGenerics 7 mins29. What is dependency injection in C# and how does the built-in container work?
mediumDesign Patterns 7 mins30. What is the difference between first-chance and second-chance exceptions in C#?
hardException Handling 7 mins31. Why does mixing blocking calls with async/await deadlock, and what does ConfigureAwait(false) do?
hardAsynchronous Programming 10 mins32. When should you return ValueTask instead of Task, and what are the rules for consuming one?
hardAsynchronous Programming 9 mins33. What are Span<T> and Memory<T> in C#, and when do you use each?
hardPerformance and Memory 11 mins34. What is IAsyncDisposable and when must you use await using instead of using?
mediumResource Management 9 mins35. What is the Large Object Heap, and how do server GC and workstation GC change your application's behaviour?
hardPerformance and Memory 11 mins36. What is a captive dependency in .NET dependency injection, and how do you detect and prevent it?
hardDependency Injection 10 mins37. What are expression trees in C#, and how do LINQ providers use them?
hardLanguage Internals 11 mins38. How do you implement cooperative cancellation with CancellationToken, and what are the common mistakes?
mediumAsynchronous Programming 10 mins39. When does using a struct hurt performance, and what do readonly struct, ref struct and in parameters fix?
hardPerformance and Memory 11 mins40. What is thread pool starvation in .NET, and how do you diagnose and fix it?
hardConcurrency and Diagnostics 12 mins41. What are C# source generators, and when should they replace runtime reflection?
hardCompilation and Tooling 11 mins42. Why can string comparison give different results on different machines, and how do you choose the right StringComparison?
mediumStrings and Globalisation 10 mins43. Why does creating a new HttpClient per request cause socket exhaustion, and what does IHttpClientFactory fix?
hardNetworking and HTTP 11 mins44. How do exception filters (catch ... when) differ from catch-and-rethrow, and why does that matter in production?
hardException Handling 10 mins45. When do you actually need a finalizer in C#, and why is SafeHandle preferred?
hardMemory and Resources 11 mins46. How do System.Threading.Channels support producer/consumer pipelines, and when would you choose them over BlockingCollection?
hardConcurrency 11 mins47. What problem does IAsyncEnumerable<T> solve, and how do you cancel and consume one correctly?
mediumAsynchronous Programming 10 mins48. How does type initialisation work in C#, and what are the TypeInitializationException and deadlock traps?
hardRuntime Behaviour 11 mins49. How can a .NET application leak memory despite garbage collection, and how do you find the cause?
hardMemory and Resources 11 mins50. How do you handle polymorphism and custom conversion in System.Text.Json, and what breaks when migrating from Newtonsoft.Json?
hardSerialisation 11 mins51. When do you use lock, SemaphoreSlim or Interlocked, and why can you not await inside a lock?
hardConcurrency 11 mins52. What breaks when you publish a .NET application trimmed or with Native AOT, and how do you make a library compatible?
hardDeployment 12 mins53. What does the C# compiler actually generate for an async method, and why does that matter for performance?
hardAsynchrony Internals 9 mins54. Why is async void dangerous, and what happens to an exception in a task nobody awaits?
mediumAsynchrony and Error Handling 8 mins55. If you await Task.WhenAll and three of the tasks fail, what exception do you see and how do you get the rest?
mediumAsynchrony and Error Handling 8 mins56. What is multiple enumeration of an IEnumerable, and how do you find and fix it in production code?
mediumLINQ and Collections 8 mins57. Explain the full dispose pattern — why is there a protected virtual Dispose(bool disposing)?
mediumResource Management 9 mins58. Nullable reference types are enabled, so why is a null still reaching production?
mediumType System 8 mins59. Two records with identical list contents compare as unequal. Why, and what else about record equality catches people out?
mediumType System 8 mins60. When would you use stackalloc versus ArrayPool for a temporary buffer, and what are the risks?
hardMemory and Performance 9 mins61. You mutate a struct stored in a List and the change disappears. What is going on?
mediumType System 8 mins