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.
How computers, operating systems, file systems and networks really work, plus the core data structures and algorithms, explained for .NET 10 engineers.
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.
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.
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.
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.
The kernel's responsibilities, CPU privilege levels (rings on x64, exception levels on Arm64), why applications run in user mode, how and when the CPU switches to kernel mode, and what that means for .NET applications, drivers, containers and security.
The system call mechanism, the path from .NET APIs through SafeHandles and the PAL to Windows (IOCP) and Linux (epoll) interfaces, the cost of crossing into the kernel, and how buffering, batching and async I/O reduce that cost. Includes tracing system calls with strace and Process Monitor.
What a process owns (address space, handles, security context) versus what a thread owns (stack, registers, thread-local storage), how threads share memory, how .NET threads map to OS threads, how the thread pool and Task build on them, and when to use multiple processes instead of threads.
Preemptive scheduling, run queues, time slices, priorities and starvation, how Windows and Linux schedulers differ at a high level, CPU affinity and NUMA, and how cgroup CPU quotas throttle containers and interact with the .NET thread pool and GC.
What the OS saves and restores on a context switch, thread versus process switches, direct and indirect costs (cache and TLB pollution), voluntary versus involuntary switches, how blocking code and oversized thread counts multiply them, and how to measure and reduce them.
Why virtual memory exists, pages and page frames, multi-level page tables, the TLB, demand paging, copy-on-write, memory-mapped files, swap and the page file, overcommit, address space layout randomisation, and what all this means for .NET processes.
Page faults, minor vs major faults, what triggers them, and how to diagnose paging-related latency in a .NET service.
File descriptors and handles as the OS's per-process references to kernel resources, their limits, and how .NET wraps them with SafeHandle and IDisposable.
Diagnosing descriptor exhaustion and socket exhaustion in .NET on Linux: ulimit, lsof, ss, TIME_WAIT, ephemeral ports, and the HttpClient/IHttpClientFactory fixes.
Files, directories, metadata, inodes and links, plus efficient directory enumeration in .NET with EnumerateFiles and EnumerationOptions.
Cross-platform path handling in .NET: separators, absolute vs relative paths, the current directory, Path.Combine vs Path.Join, case sensitivity and long paths.
Path traversal (directory traversal) in a file download endpoint, why Path.Combine does not protect you, and safe patterns including root checks, ID mapping and Zip Slip.
Unix permission bits, owners and groups, Windows ACLs, how .NET exposes them, and fixing permission errors for non-root containers with mounted volumes.
The Stream abstraction, backing vs decorator streams, Read semantics, Position and CanSeek, disposal chains, async I/O and when to use StreamReader or Pipelines.
Application, FileStream, OS page cache and device buffers; Flush vs Flush(true)/fsync; WriteThrough; atomic write-then-rename; ArrayPool for I/O buffers.
Share modes, mandatory vs advisory locking, byte-range locks, how .NET maps FileShare on each OS, finding the process holding a file, and safe cross-process coordination.