Practice answering each question out loud in your own words. Short, clear answers with a tiny example impress interviewers most.
1. What is the difference between .NET, the CLR and C#?
C# is the programming language. .NET is the platform with the runtime, libraries and tools. The CLR is the runtime that executes your compiled code (IL) with a JIT compiler, garbage collector and type safety.
2. Value types vs reference types?
| Value type | Reference type | |
|---|---|---|
| Examples | int, bool, struct, enum | class, string, arrays, delegate |
| Copy behavior | Copies the value | Copies the reference (same object) |
| Typical storage | Stack or inside the containing object | Heap object, variable holds a reference |
| Default | Zero/false | null |
3. Is string a value type? Why is it immutable?
string is a reference type that behaves like a value because it is immutable: operations create a new string. Immutability makes strings thread-safe and safe as dictionary keys. Use StringBuilder when you build text in a loop.
4. What are boxing and unboxing?
Both cost memory and time. Generics (List<int>) avoid boxing.
5. == vs Equals() vs ReferenceEquals?
==compares values for built-in types and strings, and references for classes unless overloadedEquals()compares by value if overriddenReferenceEqualsalways checks if two variables point to the same object- Records compare by value automatically
6. const vs readonly vs static readonly?
| Keyword | Set when | Notes |
|---|---|---|
const | Compile time | Only simple types, baked into callers |
readonly | Declaration or constructor | Per instance |
static readonly | Static constructor/declaration | One shared value, can be a complex object |
7. ref, out and in?
ref passes a variable by reference (must be initialized). out must be assigned by the method and is used to return extra values. in passes by reference read-only, useful for large structs.
8. Class vs struct?
| class | struct | |
|---|---|---|
| Type | Reference | Value |
| Inheritance | Yes | No (interfaces only) |
| Best for | Most objects | Small, immutable data (about 16 bytes or less) |
9. Abstract class vs interface?
| Abstract class | Interface | |
|---|---|---|
| State (fields) | Yes | No instance fields |
| Constructors | Yes | No |
| Inheritance | One base class | A class can implement many |
| Use when | Shared base code for related types | A capability or contract |
Interfaces can have default implementations since C# 8, but they remain contracts first.
10. virtual, override, new and sealed
11. What are the four OOP pillars?
- Encapsulation: hide data, expose safe members
- Abstraction: show what, hide how
- Inheritance: reuse and extend a base type
- Polymorphism: same call, different behavior
12. Property vs field?
A field stores data. A property controls access with get and set, allows validation and can be changed later without breaking callers. Expose properties, not public fields.
13. What is a record and when do you use it?
A record is a reference type (or record struct) with value-based equality, with expressions and a built-in ToString. It is ideal for DTOs and immutable data.
14. Nullable reference types?
With <Nullable>enable</Nullable> the compiler warns when a non-nullable reference might be null. string? means null is allowed. It does not change runtime behavior, it catches mistakes at compile time.
15. What is garbage collection?
The GC automatically frees memory of objects that are no longer reachable. It uses generations (0, 1, 2) so short-lived objects are cleaned cheaply. It does not close files or connections: use IDisposable and using.
16. IEnumerable vs IQueryable vs List?
IEnumerable<T>: in-memory iteration, deferred executionIQueryable<T>: builds an expression tree translated to SQL by EF CoreList<T>: a concrete collection with data already in memory
17. What is async/await?
It lets a method wait for I/O (database, HTTP) without blocking a thread. The method returns a Task and continues when the work finishes. Avoid .Result and .Wait() because they can deadlock or waste threads.
18. Task.WhenAll vs Task.WhenAny
WhenAll completes when all tasks complete. WhenAny completes when the first completes (for example a timeout race).
19. What are generics and constraints?
Generics give type safety and reuse without boxing. Constraints (where) say what a type argument must support.
20. Explain SOLID briefly
| Letter | Meaning |
|---|---|
| S | A class should have one reason to change |
| O | Open for extension, closed for modification |
| L | Subtypes must work wherever the base type is expected |
| I | Many small interfaces beat one large interface |
| D | Depend on abstractions, not concrete classes |
Conclusion
Know the core ideas and give a small example for each: types, memory, OOP, records, async and SOLID. Understanding beats memorizing.

