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

Memory

RAM, the stack and the heap, registers, CPU caches (L1, L2, L3), cache misses, memory alignment, pointers and references in .NET.

  1. What is the difference between the stack and the heap in .NET, and what actually lives where?

    How the call stack and the managed heap work, what goes in each (locals, frames, objects, boxed values, captured variables, async state), why "value types live on the stack" is a myth, and the performance and lifetime consequences.

    Junior Theory Memory Β· πŸ”— 3 follow-ups
  2. What are pointers and references in .NET? How do object references, ref/in/out parameters, ref locals, Span<T> and unsafe pointers differ?

    The spectrum from safe object references to managed pointers (ref, in, out, ref locals and ref returns, ref fields in ref structs) to unmanaged pointers in unsafe code, how the GC tracks and moves them, pinning, and when each is appropriate.

    Mid-Level Theory Memory Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world
  3. Explain the memory hierarchy: registers, L1, L2 and L3 caches, and RAM. How big and how fast is each level, and why does it matter for .NET code?

    The levels of the memory hierarchy with realistic sizes and latencies, why caches exist, how cache lines and associativity work, what is private versus shared between cores, TLBs, and how the hierarchy shapes the performance of everyday .NET code.

    Mid-Level Theory Memory Β· πŸ”— 3 follow-ups
  4. What is a cache miss? How would you find out whether cache misses are slowing down a .NET service, and how do you reduce them?

    Types of cache misses (compulsory, capacity, conflict, coherence) and TLB misses, the symptoms of memory-bound code, how to measure misses on Windows and Linux for .NET processes, and the design changes that reduce them.

    Senior Debugging Memory Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world
  5. What is memory alignment and padding? How does the CLR lay out structs and classes in memory, and when would you control layout with StructLayout?

    Natural alignment, padding and why misaligned access is slow or non-atomic, how the CLR lays out classes (auto) and structs (sequential by default, auto when they contain references), object headers and minimum object size, measuring sizes, and using StructLayout, FieldOffset, Pack and InlineArray for interop and performance.

    Senior Theory Memory Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world
  6. A .NET service suddenly crashes with a StackOverflowException. Why can't you catch it, and how do you find and fix the cause?

    How the call stack overflows, why .NET terminates the process instead of letting you catch it, common causes (unbounded or deep recursion, self-referencing properties, cyclic object graphs, large stackalloc), and how to diagnose with crash output, dumps and tests.

    Mid-Level Debugging Memory Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world
  7. Your .NET service in Kubernetes keeps getting OOMKilled even though the GC heap looks small. How do RAM, virtual memory, working set, private bytes and the GC heap relate, and how do you investigate?

    Process memory from the operating system's and the runtime's point of view: physical RAM versus virtual address space, working set, private and committed memory, the GC heap and native memory, container cgroup limits, GC heap hard limits, Server GC and DATAS, and a step-by-step investigation of OOMKilled pods.

    Senior RealWorldScenario Memory Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  8. How does the .NET managed heap allocate objects? Explain allocation contexts, generations, the large object heap and the pinned object heap.

    How allocation works on the managed heap (bump-pointer allocation in per-thread contexts), how generations and promotion keep collections cheap, when objects go to the large object heap, why pinning matters and the pinned object heap, and how to measure and reduce allocations.

    Mid-Level Theory Memory Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world

🌐 Sangam's Webring

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