📁 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.

  1. How does assembly loading work in .NET, and how do you debug a FileNotFoundException or FileLoadException for an assembly?

    Lazy loading, the TPA list from deps.json, resolution order and events, common load exceptions and the tools to trace loading.

    Senior Debugging CLR Fundamentals Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  2. What is AssemblyLoadContext, and how do you build an unloadable plugin system with it?

    Custom and collectible AssemblyLoadContext, AssemblyDependencyResolver, shared contracts and type identity, and diagnosing unload leaks.

    Senior Coding CLR Fundamentals Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  3. How does C# code become IL? Explain lowering with examples such as foreach, using, lock, string concatenation and switch.

    Roslyn lowering of high-level C# constructs into simpler C# and IL, and what Debug versus Release changes.

    Mid-Level Theory Runtime Execution Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  4. How does IL become machine code at run time, including how generic methods are compiled for reference and value types?

    The path from IL to native code: method descriptors, precode and prestub, code heap, back-patching, and shared versus specialised generic code.

    Senior Theory Runtime Execution Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  5. Which optimisations does the .NET JIT perform, and how do you write code that lets it optimise well?

    Inlining, constant folding, bounds-check elimination, devirtualisation, loop optimisations, struct promotion and escape analysis, and how to verify them.

    Senior Theory Runtime Execution Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  6. What is a method table (and the type object) in the CLR, and what is the in-memory layout of a .NET object?

    Object header, MethodTable pointer and fields; MethodTable versus EEClass versus RuntimeType; minimum object size; inspecting with SOS.

    Senior Theory Runtime Execution Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  7. What are the object header and the sync block in .NET, and how do lock and GetHashCode use them?

    Header bits for thin locks and hash codes, inflation to the sync block table, Monitor internals, and System.Threading.Lock.

    Senior Theory Runtime Execution Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world
  8. How does virtual method dispatch work in the CLR, and what does a virtual call cost compared with a direct call?

    Vtable slots in the MethodTable, the instruction sequence of a virtual call, override versus new, sealed and devirtualisation.

    Senior Theory Runtime Execution Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  9. How does interface method dispatch work in the CLR, and why can it be slower than virtual dispatch?

    Interface maps, virtual stub dispatch (indirection cells, dispatch and resolve stubs), default interface methods, constrained calls on structs.

    Senior Theory Runtime Execution Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  10. How does reflection work internally in .NET, why is it slow, and what are the faster alternatives?

    RuntimeType and member caches, Invoke costs and the .NET 7/8 invoker improvements, delegates, compiled expressions, UnsafeAccessor and source generators.

    Senior Theory Runtime Execution Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  11. How does the Roslyn compiler work, and how would you use the Roslyn APIs (syntax trees, semantic model, compilation) in your own tools?

    Roslyn's phases, immutable syntax trees, Compilation and SemanticModel, IOperation, emit, the compiler server and using the APIs to build tools.

    Senior Theory Compilation Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  12. How do you author a source generator in .NET, and how should the generator project be set up and packaged?

    Source generator authoring: IIncrementalGenerator, project setup (netstandard2.0, analyser references), post-initialisation output, debugging, packaging and pitfalls.

    Senior Coding Compilation Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  13. What makes a source generator incremental, and how do you keep a generator from slowing down the IDE?

    Incremental pipelines, caching and equality, ForAttributeWithMetadataName, avoiding symbols and syntax in models, and measuring generator performance.

    Senior Theory Compilation Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world
  14. How do you write a Roslyn analyser, and how do you test it and ship it to a team?

    Authoring DiagnosticAnalyzer: descriptors, registration actions, concurrency, generated code, testing with the Roslyn testing packages, severity configuration and packaging.

    Senior Coding Compilation Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  15. How do you write a Roslyn code fix provider, and what makes a code fix safe to apply across a whole solution?

    CodeFixProvider authoring: FixableDiagnosticIds, RegisterCodeFixesAsync, CodeAction with equivalence keys, syntax editing with trivia, Fix All and testing.

    Senior Coding Compilation Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world
  16. What are the options for build-time code generation in .NET, and how do you choose between source generators, MSBuild tasks, T4 templates and IL weaving?

    Comparing source generators, MSBuild-generated files (gRPC, OpenAPI), T4, IL weaving and interceptors for build-time code generation, with trade-offs.

    Senior Architecture Compilation Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  17. How does generational garbage collection work in .NET, and why does it make most collections cheap?

    The generational hypothesis, Gen 0/1/2, promotion, card tables and write barriers, regions, and mark-sweep-compact.

    Mid-Level Theory Garbage Collection Β· πŸ”— 4 follow-ups Β· πŸ›  1 real-world
  18. What happens during a Gen 0 allocation and collection in .NET, and how do you reduce Gen 0 GC frequency?

    Allocation contexts and bump-pointer allocation, the Gen 0 budget, what triggers a Gen 0 GC, allocation rate metrics and reducing allocations.

    Mid-Level Theory Garbage Collection Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  19. What is the role of Gen 1 in the .NET GC, and what is the "mid-life crisis" problem?

    Gen 1 as a buffer between short- and long-lived objects, Gen 1 GCs, objects that die soon after reaching Gen 2, and how to fix mid-life lifetimes.

    Senior Theory Garbage Collection Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world
  20. What is a Gen 2 (full) garbage collection in .NET, what triggers it, and how do you investigate frequent Gen 2 GCs?

    Full GCs, triggers (budget, LOH allocation, induced, low memory), blocking versus background, compaction, and a method to diagnose frequent Gen 2 collections.

    Senior Debugging Garbage Collection Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world

🌐 Sangam's Webring

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