-
What is the difference between SortedDictionary<TKey,TValue> and SortedList<TKey,TValue> in C#? How is each implemented, what are the costs of insert, lookup and enumeration, and how do you choose between them (and versus Dictionary)?
Compares the two sorted key-value collections in .NET: red-black tree versus sorted arrays, costs, memory and use cases.
Mid-Level
Theory
Collections
Β· π 2 follow-ups Β· π 1 real-world
-
When would you use LinkedList<T> in C#? Explain how it is implemented, the LinkedListNode<T> API (AddBefore, AddAfter, Remove(node)), its real costs compared with List<T>, and the classic LRU cache that combines it with a Dictionary.
The .NET doubly linked list: node API, O(1) operations given a node, memory and cache costs, and the LRU cache pattern.
Mid-Level
Coding
Collections
Β· π 3 follow-ups Β· π 1 real-world
-
What are immutable collections in .NET? Compare ImmutableArray<T>, ImmutableList<T> and ImmutableDictionary<TKey,TValue>, explain builders and structural sharing, and contrast them with ReadOnlyCollection<T>, IReadOnlyList<T> and FrozenDictionary.
System.Collections.Immutable types, their internal structures and costs, builders, and how they differ from read-only views and frozen collections.
Mid-Level
Theory
Collections
Β· π 2 follow-ups Β· π 1 real-world
-
How do the concurrent collections in .NET work? Explain ConcurrentDictionary (including the GetOrAdd and AddOrUpdate caveats), ConcurrentQueue, ConcurrentStack, ConcurrentBag and BlockingCollection, why compound operations are still not atomic, and when you would use Channel<T> instead.
System.Collections.Concurrent in depth: locking strategies, atomicity limits, delegate re-execution, expensive members and producer/consumer options.
Senior
Theory
Collections
Β· π 2 follow-ups Β· π 1 real-world
-
You are designing a new service and a colleague uses List<T> everywhere. How do you choose the right .NET collection for each job, and what collection types should your public APIs accept and return? Walk through the decision with real examples.
A senior decision framework for choosing among all .NET collections, plus API surface rules for parameters and return types.
Senior
RealWorldScenario
Collections
Β· π 2 follow-ups Β· π 1 real-world
-
How do try, catch and finally work in C#? In what order are catch blocks checked, when does finally run (and when does it not), and how do using statements relate to try/finally?
The basics of structured exception handling in C#: catch ordering, finally guarantees and limits, and using as try/finally.
Junior
Theory
Exception Handling
Β· π 2 follow-ups
-
What is the difference between throw; and throw ex; in C#? Why does throw ex lose information, how do you rethrow an exception captured on another thread with ExceptionDispatchInfo, and how do throw expressions and ThrowIf helpers fit in?
Rethrowing correctly in .NET: stack trace preservation, wrapping with inner exceptions, ExceptionDispatchInfo, throw expressions and guard helpers.
Mid-Level
Debugging
Exception Handling
Β· π 3 follow-ups Β· π 1 real-world
-
When should you create a custom exception in .NET, and how do you design one properly? Cover naming, base class, constructors, extra properties, serialisation in modern .NET, and when built-in exceptions or result types are a better choice.
Designing custom exception types: when they add value, the standard shape, domain data, and alternatives.
Mid-Level
Theory
Exception Handling
Β· π 2 follow-ups Β· π 1 real-world
-
What are exception filters (catch ... when) in C#? How do they differ from catching and rethrowing, why do they keep the stack unwound state intact, and what are good and bad uses of them?
Exception filters in C#: two-pass handling, preserving state for dumps, conditional catching by property, and pitfalls.
Mid-Level
Theory
Exception Handling
Β· π 2 follow-ups Β· π 1 real-world
-
What are inner exceptions and how do you work with exception chains in .NET? Explain InnerException, GetBaseException, AggregateException (Flatten, Handle, and what await does with it), and wrapper exceptions such as TargetInvocationException and TypeInitializationException.
Exception chains in .NET: wrapping with inner exceptions, AggregateException from tasks and parallel code, and common wrapper exceptions.
Mid-Level
Theory
Exception Handling
Β· π 2 follow-ups Β· π 1 real-world
-
How do you handle unhandled exceptions globally in .NET? Explain UseExceptionHandler, IExceptionHandler and ProblemDetails in ASP.NET Core, AppDomain.UnhandledException, TaskScheduler.UnobservedTaskException, BackgroundService failures and async void, and what a good global strategy looks like.
Global exception handling across ASP.NET Core, worker services and the runtime: last-chance hooks, ProblemDetails, and what each mechanism can and cannot do.
Senior
Architecture
Exception Handling
Β· π 2 follow-ups Β· π 1 real-world
-
How expensive are exceptions in .NET? What exactly costs time when you throw and catch, what changed in .NET 9, how do try blocks affect performance when nothing is thrown, and what patterns (Try methods, result types, throw helpers) avoid exceptions on hot paths?
The real cost of exceptions in modern .NET, how to measure exception rates, and the patterns that keep them off hot paths.
Senior
Theory
Exception Handling
Β· π 2 follow-ups Β· π 1 real-world
-
Review this exception-handling code from an order service. Identify every problem, explain why each one matters in production, and show how you would rewrite it.
A code review exercise covering the most common exception-handling mistakes in real .NET services.
Senior
CodeReview
Exception Handling
Β· π 3 follow-ups Β· π 1 real-world
-
What is the difference between a class and an object in C#? Explain how an object is created with new, where it lives, what instance and static members belong to, and how object identity differs from object equality.
Classes as blueprints and objects as runtime instances: creation, memory, instance versus static members, identity and lifetime.
Junior
Theory
Core OOP
Β· π 3 follow-ups
-
How do constructors work in C#? Explain default and parameterised constructors, chaining with this() and base(), the order of initialisation in a class hierarchy, static constructors, primary constructors (C# 12) and required members, and why calling virtual methods from a constructor is dangerous.
Everything about object construction in C#: kinds of constructors, chaining, initialisation order, static and primary constructors, required members and pitfalls.
Mid-Level
Theory
Core OOP
Β· π 2 follow-ups Β· π 1 real-world
-
Does C# have destructors? Explain finalisers, how the garbage collector runs them, why they are non-deterministic and costly, and how they relate to IDisposable, the dispose pattern and SafeHandle.
Finalisers in .NET: syntax, the finalisation queue, costs and risks, and why IDisposable and SafeHandle are the real tools for clean-up.
Senior
Theory
Core OOP
Β· π 3 follow-ups Β· π 1 real-world
-
What is encapsulation, and how do you apply it well in C#? Show the difference between a class that exposes its data and one that protects its invariants.
Encapsulation as protecting invariants: hiding state, exposing behaviour, and the C# tools that support it.
Junior
Theory
Core OOP
Β· π 2 follow-ups
-
What is abstraction in object-oriented programming, and how is it different from encapsulation? How do you design a good abstraction in C#, and what does a leaky or premature abstraction look like?
Abstraction as hiding complexity behind a simpler model, how it differs from encapsulation, and how to avoid leaky and premature abstractions.
Mid-Level
Theory
Core OOP
Β· π 3 follow-ups Β· π 1 real-world
-
How does inheritance work in C#? Explain single inheritance of classes, what a derived class inherits, base calls, member hiding with new versus overriding, protected members, and the problems that deep or misused inheritance causes.
Class inheritance in C#: mechanics, base calls, hiding versus overriding, protected access, the Liskov principle and common pitfalls.
Mid-Level
Theory
Core OOP
Β· π 2 follow-ups Β· π 1 real-world
-
What is polymorphism in C#? Explain compile-time (overloading, generics) and run-time (virtual dispatch, interfaces) polymorphism, how virtual dispatch works under the hood, and how pattern matching relates to it.
Polymorphism in C#: the kinds, how virtual and interface dispatch work, and when to use polymorphism versus pattern matching.
Mid-Level
Theory
Core OOP
Β· π 2 follow-ups Β· π 1 real-world