PUBLIC QUESTION PREVIEW
C# & .NET interview questions
C# language, async/await, LINQ, ASP.NET Core, EF Core, Dapper, CLR internals — the full Microsoft stack.
Showing 12 of 110 source questions. Sample answers are study material, not employer-specific hiring guidance.
How to work through this preview
Attempt each question before reading its answer. For a concept, give a definition and a concrete example. For code, state constraints, walk through a small input, and check complexity. For design, separate requirements from assumptions and explain failure handling. Use real situations for behavioral answers.
QUESTION 1 / easy / conceptual
What is the difference between value types and reference types in C#?
Supplied choices
- Value types are stored on the heap; reference types on the stack
- Value types store data directly and are copied by value; reference types store a heap pointer and share the same object on assignment
- Reference types are always faster than value types
- Value types cannot be null under any circumstances
Source answer choice: B. Value types store data directly and are copied by value; reference types store a heap pointer and share the same object on assignment
Sample answer
Hints to guide your next attempt
- Where is each stored in memory?
- What happens when you assign one to another?
Source tags: value-types / reference-types / memory / stack / heap / csharp
QUESTION 2 / medium / conceptual
How does async/await work under the hood in C#? What is a state machine?
Sample answer
Hints to guide your next attempt
- The compiler transforms async methods into a state machine
- await does NOT block the thread — what does it do instead?
Source tags: async / await / state-machine / synchronization-context / csharp
QUESTION 3 / easy / conceptual
What is a delegate in C#? How does it differ from an event?
Supplied choices
- Delegates are only for methods returning void; events can return any type
- Events can be invoked from any class; delegates can only be invoked from within the declaring class
- Delegates define a method signature and are type-safe function pointers; events add restrictions preventing external invocation and direct assignment
- There is no difference — event is purely syntactic sugar with identical runtime behavior
Source answer choice: C. Delegates define a method signature and are type-safe function pointers; events add restrictions preventing external invocation and direct assignment
Sample answer
Hints to guide your next attempt
- Delegate = type-safe function pointer
- Event restricts what outside code can do with the delegate
Source tags: delegate / event / multicast / publisher-subscriber / csharp
QUESTION 4 / medium / conceptual
What is LINQ deferred execution? When does it cause bugs?
Sample answer
Hints to guide your next attempt
- When does a LINQ query actually execute?
- What if the source collection changes between definition and iteration?
Source tags: linq / deferred-execution / lazy-evaluation / ienumerable / csharp
QUESTION 5 / easy / conceptual
What are generics in C#? What are type constraints and when do you use them?
Sample answer
Hints to guide your next attempt
- Generics = compile-time type safety without boxing
- Constraints open up operations on T
Source tags: generics / type-constraints / type-safety / csharp
QUESTION 6 / medium / conceptual
What is the difference between IEnumerable<T> and IQueryable<T>?
Supplied choices
- IQueryable is faster for in-memory collections; IEnumerable is for database queries
- Both execute queries in memory — the difference is just compile-time type checking
- IEnumerable executes LINQ in C# memory; IQueryable builds an expression tree executed server-side (e.g. as SQL)
- IQueryable is deprecated in .NET 6+
Source answer choice: C. IEnumerable executes LINQ in C# memory; IQueryable builds an expression tree executed server-side (e.g. as SQL)
Sample answer
Hints to guide your next attempt
- Where is the filtering done — in C# memory or on the database server?
- Which one builds an expression tree?
Source tags: ienumerable / iqueryable / linq / ef-core / expression-tree / csharp
QUESTION 7 / medium / conceptual
What is boxing and unboxing in C#? Why does it matter for performance?
Supplied choices
- Boxing only affects string types and has minimal performance impact
- Boxing allocates a heap object wrapping the value type — adds GC pressure and memory copy overhead
- Boxing is handled by the JIT so it has zero runtime performance impact
- Boxing only occurs when using reflection APIs
Source answer choice: B. Boxing allocates a heap object wrapping the value type — adds GC pressure and memory copy overhead
Sample answer
Hints to guide your next attempt
- What heap allocation happens when you box a value type?
- Where did this commonly occur in pre-generics code?
Source tags: boxing / unboxing / performance / gc / value-types / csharp
QUESTION 8 / medium / coding
Implement the IDisposable pattern correctly in C#. What is the "using" statement?
Sample answer
Hints to guide your next attempt
- Dispose(bool disposing) separates managed vs unmanaged cleanup
- GC.SuppressFinalize prevents double-cleanup
Source tags: idisposable / using / finalizer / resource-management / csharp
QUESTION 9 / easy / conceptual
What is the difference between struct and class in C#? When should you use a struct?
Supplied choices
- Structs support inheritance from other structs but not from classes
- Structs are always allocated on the heap just like classes
- Structs are value types — stack-allocated by default, copied by value, no inheritance; classes are reference types stored on the heap
- Classes are always faster than structs because they avoid copying
Source answer choice: C. Structs are value types — stack-allocated by default, copied by value, no inheritance; classes are reference types stored on the heap
Sample answer
Hints to guide your next attempt
- Value type vs reference type
- Stack vs heap, no inheritance, size matters
Source tags: struct / class / value-type / reference-type / performance / csharp
QUESTION 10 / easy / conceptual
What is the difference between const and readonly in C#?
Supplied choices
- const can be assigned in a constructor; readonly must be assigned at the declaration site
- Both are evaluated at compile time — they are interchangeable
- const is inlined at compile time and must be a primitive; readonly is a runtime constant settable in the constructor
- readonly is implicitly static; const is instance-level
Source answer choice: C. const is inlined at compile time and must be a primitive; readonly is a runtime constant settable in the constructor
Sample answer
Hints to guide your next attempt
- When is each evaluated — compile time or runtime?
- Which can be set in a constructor?
Source tags: const / readonly / compile-time / immutability / csharp
QUESTION 11 / medium / conceptual
What are extension methods in C#? When and how do you write one?
Sample answer
Hints to guide your next attempt
- Static class, static method, first parameter with "this" keyword
- Adds methods to types you don't own
Source tags: extension-methods / static / linq / csharp
QUESTION 12 / medium / conceptual
What is the difference between Func<T>, Action<T>, and Predicate<T> in C#?
Sample answer
Hints to guide your next attempt
- Focus on return types
- Predicate<T> is a specialized Func<T,bool>
Source tags: func / action / predicate / delegates / higher-order-functions / csharp
Check understanding, not recognition
- Can you explain the answer without reading it?
- Can you show when the approach fails or needs a different assumption?
- Can you connect the concept to a real project, task, or decision you have made?
- Can you distinguish a simplified interview example from a production requirement?
A LITTLE MORE CLARITY
Frequently asked questions
How many C# & .NET questions are shown here?
This public preview shows 12 questions with the supplied answers from the app's 110-question C# & .NET bank. Full interactive practice requires signing in.
Should I memorize the sample answers?
Use them as reference explanations, not a script or a guarantee of technical correctness for every environment. Explain your assumptions, validate code against your language and version, and discuss trade-offs. Behavioral answers should be built from your own experience.
What do hints and solution steps mean?
Hints identify ideas to consider before reading the answer. When the source question includes steps, they are shown as a separate walkthrough. Example capacities and design targets in a solution are assumptions for that exercise, not real system statistics.
BUILD YOUR NEXT OPPORTUNITY
Practice C# & .NET actively.
Sign in to use the full topic bank and interactive practice workspace.