1. Home
  2. Docs
  3. Interview Technical Quest...
  4. C# Interview Cheat Sheet – Top 30 Must-Know Questions & Answers

C# Interview Cheat Sheet – Top 30 Must-Know Questions & Answers

1. C# Basics

1. What is C#? – Modern, object-oriented language for .NET apps.
2. Value vs Reference types – Value stores data; reference stores memory address.
3. const vs readonlyconst: compile-time, readonly: runtime/constructor.
4. Boxing/Unboxing – Convert value type ↔ object.
5. String vs StringBuilder – String immutable, StringBuilder mutable for performance.


2. OOP Concepts

6. 4 Pillars of OOP – Encapsulation, Abstraction, Inheritance, Polymorphism.
7. abstract vs interface – Abstract: implemented methods allowed, cannot instantiate; Interface: contract only (C# 8+ allows default methods).
8. Method Overloading vs Overriding – Overload: same name, different signature; Override: redefine virtual method.
9. virtual, override, new – Virtual: overridable; Override: override base; New: hides base method.
10. sealed class – Cannot be inherited.


3. Collections & Generics

11. List vs Array – List: dynamic, Array: fixed size
12. Dictionary vs Hashtable – Dictionary: generic, type-safe; Hashtable: non-generic
13. Stack vs Queue – Stack: LIFO; Queue: FIFO
14. IEnumerable vs ICollection – IEnumerable: iteration only; ICollection: count, add/remove
15. Generic Method Example:

public T Max<T>(T a, T b) where T : IComparable<T> => a.CompareTo(b) > 0 ? a : b;

4. LINQ

16. What is LINQ? – Query language integrated into C#
17. Deferred Execution – Query executes when enumerated
18. Select vs SelectMany – SelectMany flattens nested collections
19. First, FirstOrDefault, Single, SingleOrDefault – Different ways to select elements safely
20. IQueryable vs IEnumerable – IQueryable: executed on database; IEnumerable: executed in memory


5. Async / Multithreading

21. async / await – Non-blocking asynchronous methods
22. Task vs Thread – Task: abstraction over async work; Thread: OS-level execution
23. Deadlock – Threads waiting on each other indefinitely; prevent by careful locking
24. ThreadPool – Managed reusable threads
25. CancellationToken – Allows cooperative task cancellation


6. Exception Handling

26. try-catch-finally – Standard exception handling
27. throw vs throw ex – throw preserves stack trace, throw ex resets it
28. Custom Exceptions – Create user-defined exceptions by inheriting Exception
29. Best Practices – Catch specific exceptions, log, rethrow if necessary


7. Design Patterns & Miscellaneous

30. Singleton Pattern – Ensure one instance of a class; example:

public class Singleton
{
    private static Singleton _instance;
    private static readonly object _lock = new object();
    private Singleton() {}
    public static Singleton Instance
    {
        get
        {
            lock(_lock)
            {
                if (_instance == null)
                    _instance = new Singleton();
                return _instance;
            }
        }
    }
}

Quick Notes / Code Snippets

  • Ref vs Out: ref initialized before method, out assigned inside method
  • Extension Method:
public static bool IsEven(this int n) => n % 2 == 0;
  • Async Stream:
await foreach(var item in GetItemsAsync()) { Console.WriteLine(item); }
  • LINQ Example:
var evenNumbers = numbers.Where(n => n % 2 == 0).ToList();
  • Dependency Injection:
services.AddScoped<IMyService, MyService>();

This one-page cheat sheet covers:

  • Core syntax & OOP
  • Collections & LINQ
  • Async & multithreading
  • Exceptions
  • Design patterns

It’s perfect to skim the night before or during quick revisions.

How can we help?