Interview Prep | C#
C# Interview Questions

Entry, Mid, and Advanced C# questions with short answers. Use search to filter questions quickly.

🔍

C# Entry Level Q&A

Back to Top ↑
🔷
Q1. What is CLR?
A. Common Language Runtime runs .NET code, provides JIT, GC, type safety, and exception handling.
Entry
🔷
Q2. Value types vs reference types?
A. Value types (struct) store data directly; reference types (class) store references to heap objects.
Entry
🔷
Q3. What is boxing/unboxing?
A. Boxing wraps a value type in object (allocates). Unboxing extracts the value type.
Entry
🔷
Q4. string vs StringBuilder?
A. string is immutable; StringBuilder is mutable and better for many concatenations.
Entry
🔷
Q5. What is a property?
A. A member with get/set accessors, often used to encapsulate fields.
Entry
🔷
Q6. What is an interface?
A. A contract of members a class/struct implements.
Entry
🔷
Q7. Exception handling in C#?
A. try/catch/finally; throw to rethrow; catch specific exceptions first.
Entry
🔷
Q8. What is a delegate?
A. A type-safe function pointer; events are based on delegates.
Entry

C# Mid Level Q&A

Back to Top ↑
⚙️
Q1. What is LINQ?
A. Query operators for collections; works with IEnumerable and IQueryable.
Mid
⚙️
Q2. IEnumerable vs IQueryable?
A. IEnumerable executes in memory; IQueryable can be translated by providers (e.g., to SQL).
Mid
⚙️
Q3. What is deferred execution?
A. Many LINQ queries execute only when enumerated (foreach/ToList).
Mid
⚙️
Q4. What is async/await?
A. Task-based async; await yields without blocking thread and resumes via continuation.
Mid
⚙️
Q5. Task vs Thread?
A. Thread is OS thread. Task is an async operation (usually uses thread pool).
Mid
⚙️
Q6. What is an extension method?
A. Static method that appears as instance method using this on first parameter.
Mid
⚙️
Q7. What does lock do?
A. It uses Monitor.Enter/Exit to synchronize access to a critical section.
Mid
⚙️
Q8. What is IDisposable?
A. Pattern for deterministic cleanup; used with using statements.
Mid

C# Advanced Level Q&A

Back to Top ↑
🚀
Q1. What is SynchronizationContext?
A. Controls where continuations run (e.g., UI thread). ConfigureAwait(false) can avoid capturing context.
Advanced
🚀
Q2. How to avoid deadlocks with async?
A. Avoid blocking on Tasks (.Result/.Wait), use async all the way, and configure context appropriately.
Advanced
🚀
Q3. What is GC and generations?
A. Managed memory is collected by GC; generations (0/1/2) optimize for short-lived objects.
Advanced
🚀
Q4. What is Span<T>?
A. A stack-only type for slicing memory safely without allocations.
Advanced
🚀
Q5. What is variance (covariance/contravariance)?
A. Generic variance rules (out/in) enabling safe subtype assignment.
Advanced
🚀
Q6. What is thread-safety?
A. Correct behavior under concurrency; avoid races using locks, immutability, and concurrent collections.
Advanced
🚀
Q7. What is a memory leak in .NET?
A. Holding references prevents GC (event handlers, static caches). Unmanaged resources also need disposal.
Advanced
🚀
Q8. What is a cancellation token?
A. Cooperative cancellation for async operations and long-running tasks.
Advanced