📁 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 1 — Computer Science Fundamentals

How computers, operating systems, file systems and networks really work, plus the core data structures and algorithms, explained for .NET 10 engineers.

  1. What actually happens between writing C# source code and the CPU executing it?

    The full journey of .NET code: Roslyn compiles C# to IL, the runtime loads the assembly, the JIT (with tiered compilation and Dynamic PGO) or an AOT compiler turns IL into machine code, and the CPU runs those instructions.

    Junior Theory Computer Basics Β· πŸ”— 2 follow-ups
  2. Explain binary, decimal and hexadecimal. How do you convert between them, and why do developers use hexadecimal so often?

    Positional number systems (base 2, 10 and 16), converting between them by hand and in C#, and why hex is the natural way to read bytes, memory addresses, colours, hashes and GUIDs.

    Beginner Theory Computer Basics Β· πŸ”— 2 follow-ups
  3. What are bits and bytes, how big are the .NET numeric types, and what happens when an int overflows?

    Bits, bytes and two's complement; the sizes and ranges of C# numeric types; unchecked versus checked overflow; and bitwise operations and flags enums.

    Junior Coding Computer Basics Β· πŸ”— 2 follow-ups
  4. What is character encoding? Explain ASCII and Unicode, and the difference between a character, a code point and a code unit.

    Why text needs an encoding, what ASCII covers and where it stops, how Unicode assigns code points, and how code points, code units, bytes and user-perceived characters (grapheme clusters) differ.

    Junior Theory Computer Basics Β· πŸ”— 2 follow-ups
  5. How do UTF-8 and UTF-16 differ, and why can string.Length give the wrong answer for user-visible characters in .NET?

    How UTF-8 and UTF-16 encode code points, surrogate pairs, why .NET strings are UTF-16 internally, when UTF-8 is used, and how to count, slice and limit text correctly with Rune and StringInfo.

    Mid-Level Theory Computer Basics Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world
  6. Customers report names like "José" in a CSV export opened in Excel, and an imported file shows "Jos�". How do you diagnose and fix these encoding problems?

    A practical debugging walkthrough for mojibake and replacement characters: reading the bytes in hex, identifying UTF-8 versus Windows-1252 and double encoding, the BOM and Excel, and fixing both export and import paths in .NET.

    Mid-Level Debugging Computer Basics Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world
  7. What is endianness, and how do you read and write multi-byte binary data correctly in .NET?

    Big-endian versus little-endian byte order, which platforms and protocols use which, network byte order, and the .NET APIs (BinaryPrimitives, BinaryReader, BitConverter, Guid) that handle byte order explicitly or implicitly.

    Mid-Level Theory Computer Basics Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world
  8. Review this C# method that builds a fixed-layout binary message for a partner system, including a customer name field limited to 32 bytes. What is wrong and how would you fix it?

    A code review that combines encoding and endianness: ASCII data loss, truncating by chars instead of bytes, splitting surrogate pairs, BitConverter's machine byte order, missing validation, and an allocation-free rewrite with BinaryPrimitives and UTF-8.

    Senior CodeReview Computer Basics Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world
  9. What are the main parts of a CPU (cores, registers, ALU, control unit and caches), and how do they work together to run your code?

    A tour of CPU architecture for software engineers: cores and hardware threads, the register file, the ALU and other execution units, the control unit, the cache hierarchy and the clock, and why each matters for .NET performance.

    Junior Theory CPU Β· πŸ”— 3 follow-ups
  10. Walk through the fetch-decode-execute instruction cycle. How does it apply to the machine code the .NET JIT generates?

    The instruction cycle (fetch, decode, execute, memory access, write-back), the instruction pointer, how jumps, calls and returns change the flow, and how to read a few lines of JIT-generated x64 or Arm64 assembly.

    Junior Theory CPU Β· πŸ”— 3 follow-ups
  11. What is CPU pipelining, and how do superscalar and out-of-order execution make modern CPUs fast? What stalls a pipeline?

    Instruction pipelining, superscalar issue, out-of-order execution with register renaming and the reorder buffer, the hazards that stall pipelines (data dependencies, branches, cache misses), and how dependency chains show up in .NET code.

    Mid-Level Theory CPU Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  12. Why can a loop over a sorted array run much faster than the same loop over unsorted data? Explain branch prediction and how to write branch-friendly .NET code.

    How CPUs predict conditional and indirect branches, what a misprediction costs, the classic sorted-versus-unsorted example, branchless techniques, how the .NET JIT uses conditional moves and Dynamic PGO, and how to measure mispredictions.

    Senior Coding CPU Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world
  13. What is cache locality? Why is iterating a 2D array row by row much faster than column by column, and how should it influence your choice of .NET data structures?

    Spatial and temporal locality, cache lines and hardware prefetching, row-major layout of C# multidimensional arrays, arrays of structs versus arrays of references, struct-of-arrays layouts, and benchmarking the effects.

    Mid-Level Coding CPU Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world
  14. A parallel loop that updates per-thread counters gets slower as you add cores. What is false sharing, how do you detect it, and how do you fix it in .NET?

    Cache coherence and why two threads writing different variables on the same cache line slow each other down, how to recognise and measure false sharing, and fixes: thread-local accumulation, padding, and avoiding shared writes.

    Senior Debugging CPU Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world
  15. How do x64 and Arm64 CPU architectures differ, and what does a .NET team need to check before running services on Arm64 servers or developing on Apple Silicon?

    CISC versus RISC design, instruction sets, memory ordering models and SIMD differences between x64 and Arm64, and the practical checklist for .NET: RIDs, native dependencies, multi-arch container images, concurrency correctness, performance testing and cost.

    Mid-Level Theory CPU Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  16. What is SIMD, how do CPU vector registers work, and when would you use Vector128<T>, Vector256<T> or Vector<T> in .NET?

    Single instruction, multiple data: vector registers and instruction sets (SSE, AVX2, AVX-512, NEON), the .NET hardware-intrinsic APIs, vectorised BCL methods and TensorPrimitives, writing a vectorised loop with a scalar tail, and when SIMD is or isn't worth it.

    Senior Coding CPU Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world
  17. 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
  18. 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
  19. 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
  20. 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

🌐 Sangam's Webring

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