Top 50 C# Intermediate Interview Questions and Answers
A collection of the most important intermediate C# interview questions covering OOP, delegates, LINQ, collections, async/await, SOLID, generics, memory management, and .NET internals.
1. What is the difference between IEnumerable and IQueryable?
- IEnumerable: Executes queries in memory (LINQ to Objects).
- IQueryable: Executes queries in database (LINQ to SQL/EF).
2. What is the difference between ref and out?
- ref: Must be initialized before passing.
- out: Must be assigned inside the method.
3. What are Generics in C#?
A feature that allows type-safe data structures without boxing/unboxing.
Example: List<T>.
4. What is the difference between Interface and Abstract Class?
- Interface: Only declarations.
- Abstract class: Can have implementation + abstract methods.
- A class can implement multiple interfaces but only inherit one abstract class.
5. What is a Delegate?
A type-safe pointer to a method.
6. What is a Multicast Delegate?
A delegate that can hold multiple methods using +=.
7. What is an Event?
A wrapper around delegates used for publish–subscribe communication.
8. What is the difference between Func, Action, and Predicate?
- Func: returns value
- Action: returns void
- Predicate: returns bool
9. What is Dependency Injection (DI)?
A design pattern to remove class dependencies using:
- Constructor injection
- Property injection
- Method injection
10. What is SOLID in C#?
Five principles:
S – Single Responsibility
O – Open/Closed
L – Liskov Substitution
I – Interface Segregation
D – Dependency Inversion
11. What is Boxing/Unboxing?
- Boxing: Value → Reference
- Unboxing: Reference → Value
12. Difference between String and StringBuilder?
- String is immutable.
- StringBuilder is mutable, faster for modifications.
13. What is Extension Method?
Adds new methods to existing types without modifying them using this keyword.
14. What is Anonymous Method?
A method without a name defined using the delegate keyword.
15. What is Lambda Expression?
A shorthand anonymous function using =>.
16. What is Var vs Dynamic?
- var: compile-time type
- dynamic: runtime type
17. What is the difference between const and readonly?
- const: compile-time constant
- readonly: runtime constant
18. What is Polymorphism?
Method overloading (compile-time) & method overriding (run-time).
19. What is Shadowing (new keyword)?
Hiding base class method using new.
20. What is Virtual Keyword?
Allows a method to be overridden in derived classes.
21. What is Abstract Method?
A method declared but not implemented in abstract class.
22. What is Interface Default Implementation (.NET 8+)?
Interfaces can contain method bodies using default keyword.
23. What is Thread?
A lightweight process used for parallel execution.
24. What is Thread Pool?
Pre-created worker threads managed by CLR for performance.
25. What is Deadlock?
Two threads waiting indefinitely for each other’s resources.
26. What is Async/Await?
Used for non-blocking asynchronous programming.
27. What is Task Parallel Library (TPL)?
A set of APIs for parallel processing using Task.
28. Difference between Task and Thread?
- Task: higher-level abstraction
- Thread: low-level OS thread
29. What is Lock in C#?
A mechanism to prevent multiple threads accessing shared resources.
30. What is Monitor Class?
A more advanced locking mechanism than lock keyword.
31. What is Garbage Collection?
Automatic memory cleanup in .NET.
32. What are GC Generations?
- Gen 0
- Gen 1
- Gen 2
- Higher gen = older objects.
33. What is IDisposable Interface?
Used to release unmanaged resources using Dispose().
34. What is Using Statement?
Automatically calls Dispose().
35. What is Managed vs Unmanaged Code?
- Managed: controlled by CLR
- Unmanaged: outside CLR (COM, Win32)
36. What is Reflection?
Allows inspection of types at runtime.
37. What is late binding?
Type resolved at runtime using reflection/dynamic.
38. What is Attribute in C#?
Metadata applied to classes/methods like [Obsolete].
39. What is Serialization?
Converting object → data format (JSON, XML).
Opposite: Deserialization.
40. What is async state machine?
Compiler converts async/await into a state machine.
41. What is LINQ?
Language Integrated Query used for data querying.
42. Types of LINQ?
- LINQ to Objects
- LINQ to SQL
- LINQ to Entities
- LINQ to XML
43. What is Deferred Execution?
Query executes only when iterated.
44. What is Immediate Execution?
Query executed immediately using methods like:
- ToList()
- Count()
- First()
45. What are Joins in LINQ?
Inner, Left, Right, Full, Group Join.
46. What is PLINQ?
Parallel LINQ for multi-threaded queries.
47. What are Collections in C#?
- List
- Dictionary
- HashSet
- Queue
- Stack
48. Difference between List and Dictionary?
- List: index-based
- Dictionary: key-value pairs
49. What is Immutable Collection?
Collection whose elements cannot be changed. Available in System.Collections.Immutable.
50. What are Tuples in C#?
Lightweight structure to store multiple values.
Example: