📁 Sangam Dhakal - Portfolio v2.0 - Netscape Navigator 4.0
_
□
×

πŸ“š .NET Interview Questions

377 questions for senior .NET engineer interviews, each with a 30-second answer, the full answer, a deep dive, the follow-ups interviewers ask next, and real-world production problems.

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.

  1. 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
  2. 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
  3. 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
  4. 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
  5. 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
  6. 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
  7. 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
  8. 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
  9. 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
  10. 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

🌐 Sangam's Webring

βͺ Previous 🏠 Main Next ⏩
πŸ’¬ Chat with me