✅ C# Interview Guide — Explained by a .
NET Developer
✅ Section 1: C# Basics
1. What is C#? Expected Answer: C# is an object-oriented, type-safe programming language
developed by Microsoft. It's primarily used for developing applications on the .NET platform including
desktop, web, mobile, and cloud. It supports modern features like asynchronous programming
( async/await ), LINQ for data querying, and strong type checking.
2. What is the .NET Framework? Expected Answer: The .NET Framework is a development platform
for building Windows applications. It includes:
• CLR (Common Language Runtime) for memory and thread management
• BCL (Base Class Library) for built-in functionality
• Support for multiple languages like C#, VB.NET, and F# .NET Core and .NET 6+ are cross-platform
evolutions of the original .NET Framework.
3. Value vs Reference Types? Expected Answer:
• Value types (e.g., int , float ) store data directly and live on the stack.
• Reference types (e.g., class , string ) store references and live on the heap.
• Value types can't be null unless declared as nullable ( int? ).
4. Difference between == and .Equals()? Expected Answer:
• == compares references for objects and values for value types.
• .Equals() checks for content equality and can be overridden. Use .Equals() when
comparing strings or custom objects.
5. What are nullable types in C#? Expected Answer: Allows value types to hold null . Useful in
database operations.
int? age = null;
if (age.HasValue) { ... }
6. const vs readonly? Expected Answer:
• const is a compile-time constant (must be assigned at declaration)
• readonly can be assigned in constructor (runtime constant)
• Use readonly for object references that can’t change
7. What is boxing/unboxing? Expected Answer:
• Boxing: value type → object (heap)
• Unboxing: object → value type (stack)
1
object obj = 5; // boxing
int i = (int)obj; // unboxing
Use generics to avoid performance hits from boxing.
8. Use of var? Expected Answer:
• var allows implicit type inference by compiler
• Still strongly typed at compile-time
var name = "John"; // compiler infers string
9. Access Modifiers? Expected Answer:
• public : accessible anywhere
• private : inside the same class only
• protected : class and subclasses
• internal : same assembly
10. Static vs Non-static class? Expected Answer:
• Static: can’t be instantiated, all members static
• Non-static: supports object creation Use static for utility/helper classes.
✅ Section 2: OOP Concepts
11. Encapsulation? Encapsulation is the process of hiding internal object state via access modifiers and
exposing safe public APIs through methods/properties.
12. Inheritance? Inheritance allows one class (child) to inherit properties and methods of another
(base).
class Car : Vehicle { }
13. Polymorphism? Two types:
• Compile-time (overloading)
• Runtime (overriding with virtual / override )
14. Abstraction? Hiding implementation and showing only essential features using abstract classes
or interface s.
15. Method Overloading? Same method name with different parameters.
void Print(int a); void Print(string b);
2
16. Method Overriding? Child class modifies base class method.
public override void Speak() { ... }
17. Abstract Classes? Can’t be instantiated, may contain abstract + concrete methods.
18. Interface? Only method signatures, no implementation. Classes implement interfaces to follow a
contract.
**19. Abstract vs Interface?
Feature Abstract Class Interface
Methods Abstract + Concrete Only Abstract (till C# 8)
Inheritance Single inheritance Multiple allowed
Fields Yes No
20. Multiple Inheritance? C# doesn't support it for classes but allows a class to implement multiple
interfaces.
✅ Section 3: Intermediate Features
21. Constructor? Runs on object creation; initializes values.
22. Destructor? Used to clean up unmanaged resources. Declared as ~ClassName() .
23. Properties? Encapsulated fields:
public int Age { get; set; }
24. Indexer?
public string this[int i] => data[i];
Access objects like arrays.
25. Delegates? Type-safe pointers to methods.
delegate void MyDelegate(string s);
26. Events? Encapsulate delegate logic. Used in UI/event-driven models.
27. Exception Handling? Use try-catch-finally . Handle specific or general exceptions.
3
28. finally block? Executes always — useful for closing connections.
29. params keyword? Method takes variable arguments:
void Log(params string[] messages)
30. sealed class? Prevent inheritance.
sealed class Logger { }
✅ Section 4: Collections & LINQ
31. Array? Fixed-size, strongly typed.
int[] arr = new int[5];
32. Array vs ArrayList?
• Array: fixed, type-safe
• ArrayList: resizable, object-based Prefer List<T> over ArrayList.
33. List? Generic resizable collection.
List<int> nums = new List<int>();
34. Dictionary\<TKey, TValue>? Hash-based key-value storage.
var dict = new Dictionary<string, int>();
35. LINQ? Query syntax in C#.
var result = from x in list where x > 10 select x;
36. LINQ to get evens?
var evens = from n in nums where n % 2 == 0 select n;
37. Anonymous Types?
var person = new { Name = "Tom", Age = 25 };
4
Temporary, read-only types.
38. IEnumerable vs IEnumerator?
• IEnumerable: returns IEnumerator
• IEnumerator: supports MoveNext() + Current
39. yield keyword? Used in iterators:
yield return item;
Maintains state across iterations.
40. Lambda Expression? Shorthand for anonymous functions:
x => x * x;
Useful in LINQ and delegate scenarios.
✅ Section 5: Memory & Runtime
41. Garbage Collection? Automatic memory cleanup for unused objects. Reduces memory leaks.
42. GC Generations?
• Gen 0: short-lived
• Gen 1: medium-lived
• Gen 2: long-lived
43. Stack vs Heap?
• Stack: method frames, value types
• Heap: reference types, managed by GC
44. Unsafe Code? Allows pointer use (like C++). Use unsafe { } and compile with /unsafe .
45. using Statement? Auto-dispose objects implementing IDisposable :
using (var conn = new SqlConnection(...)) { }
Avoids resource leaks.
Let me know if you want mock interview Q&A based on these topics or a quiz format!