C# Interview Questions for Senior .NET Engineer - Питання та відповіді

Programming
Previous

🧠 Core Language & Fundamentals

  • What is the difference between class / struct / record in C#?
    When would you use them?

In C#, a class is a reference type, mutable by default, supports inheritance, and uses reference equality unless overridden.
A struct is a value type, copied when passed, and typically used for small, performance-critical data.
A record is mainly for immutable data with value-based equality, supports with expressions, deconstruction, and a generated ToString().
A record struct combines value-type semantics with value-based equality, and is mutable by default.

Usage: classes for complex or inheritable objects, structs for small values, and records for immutable data models or DTOs.

What happens if a record contains a property that is a class and you use a with expression? How does it affect equality and mutability?

  • Explain the difference between interface and abstract class.
  • What is boxing and unboxing? When does it happen?
  • What is the difference between == and .Equals()?
  • What are value types vs reference types?

⚡ Memory Management & Performance

  • How does garbage collection work in .NET?
  • What are generations in GC?
  • What is the Large Object Heap (LOH)?
  • What is Span<T> and when should you use it?
  • How can you reduce memory allocations in C#?
  • What are common performance pitfalls in C#?

🔄 Async / Await & Multithreading

  • How does async/await work under the hood?
  • What is the difference between Task and Thread?
  • What is the difference between Task and ValueTask?
  • What happens if you don’t await a task?
  • What is a deadlock in async code? How can you avoid it?
  • What is ConfigureAwait(false) and when should you use it?
  • Difference between Parallel.ForEach and Task.WhenAll?

🧵 Threading & Concurrency

  • What is a race condition?
  • What synchronization primitives do you know (lock, Monitor, SemaphoreSlim, etc.)?
  • What is the difference between lock and Mutex?
  • What is thread safety and how do you ensure it?
  • What are concurrent collections?

🔗 LINQ & Collections

  • How does LINQ work internally?
  • What is deferred execution?
  • Difference between IEnumerable and IQueryable?
  • When does LINQ execute a query?
  • What are the performance implications of LINQ?
  • Difference between Select and SelectMany?

🧩 Delegates, Events & Functional Features

  • What is a delegate?
  • Difference between Action, Func, and Predicate?
  • What are events and how are they used?
  • What are lambda expressions?
  • What are closures in C#?

🏗️ OOP & Design

  • What are SOLID principles? (briefly explain each)
  • What is dependency injection?
  • What is inversion of control?
  • What are common design patterns used in C#?

📦 Advanced Language Features

  • What are yield return and iterators?
  • What are extension methods?
  • What is pattern matching in C#?
  • What are nullable reference types?
  • What is reflection and when would you use it?

🔍 Exception Handling

  • What is the difference between throw and throw ex?
  • When should you use custom exceptions?
  • What are best practices for exception handling?

🧪 Practical / Real-world

  • How would you debug a memory leak in a .NET application?
  • How do you handle high-load scenarios in C#?
  • How do you profile performance in a .NET app?
  • Can you describe a challenging bug you solved in C#?

Базові, але обов’язкові (часто валять кандидатів):
Explain the difference between value types and reference types.
What is boxing and unboxing?
What is the difference between ArrayList and List<T>?
What are delegates and events and how do they work?


Async / Threading (дуже часто на Senior)
Explain how async/await works internally
What is the difference between Task and Thread?
What is a deadlock in async code?
What is ConfigureAwait(false) and when would you use it?

LINQ / Collections
What is the difference between IEnumerable, IQueryable, and IAsyncEnumerable?
When does LINQ query execute?
What is deferred execution?

Практичні задачі
Reverse a string
Remove duplicates from a list
Check if brackets in a string are valid
Merge overlapping ranges (e.g. [1-3, 2-4] → [1-4])
Sort and reverse an array


Архітектура + реальний досвід (Senior рівень)
Describe a complex system you built
What problems did you face and how did you solve them?
How would you design a high-load API?
How do you handle performance issues in a system?

🧠 Garbage Collector / Runtime (часто для Senior)
How does Garbage Collection work?
What are GC generations?
What is LOH (Large Object Heap)?


🧩 tricky / conceptual (що часто «ламає» кандидатів)
What happens if you change a class to struct?
What goes to stack vs heap?
What causes StackOverflowException vs OutOfMemoryException?


🗄️ DB / EF (реальні питання)
Can DbContext be a singleton?
Explain SQL join types
Design a database schema (Movies, Orders, etc.)

Самостоятельный отпуск Опыт заказа вывоза мусора в Киеве Магія зміни: Від ночі до дня
Магія Вечірнього Неба: Відлякуйте втомленість дня і зануртеся у світ загадок і краси Якби Росія була людиною, то як би її описав психіатр?