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

Runtime Execution

How C# becomes machine code, JIT optimisations, object layout (method tables, headers, sync blocks), virtual and interface dispatch, and reflection internals.

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

🌐 Sangam's Webring

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