Phase 2 — C# Fundamentals
The C# language core for .NET 10 and C# 14: language basics, the type system, strings, arrays, collections and exception handling, with the internals and trade-offs senior interviews probe.
-
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