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

Synchronization

lock, Monitor, Mutex, Semaphore, SemaphoreSlim, SpinLock, ReaderWriterLockSlim, Interlocked, Volatile and memory barriers.

  1. How does the lock statement work in C#, and what changed with System.Threading.Lock in .NET 9 and C# 13?

    lock lowering to Monitor or Lock.EnterScope, choosing the lock object, re-entrancy, why you cannot await inside a lock, and lock scope design.

    Mid-Level Theory Synchronization Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  2. What does the Monitor class provide beyond the lock statement? Explain TryEnter, Wait and Pulse.

    Monitor.Enter/Exit, TryEnter with timeouts, Wait/Pulse/PulseAll condition signalling, thread affinity and the object header thin lock and sync block.

    Senior Theory Synchronization Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  3. What is a Mutex in .NET, how is it different from lock, and when would you use a named Mutex?

    Kernel mutex, cross-process named mutexes, Global and Local prefixes, AbandonedMutexException, thread affinity, cost and single-instance apps.

    Mid-Level Theory Synchronization Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world
  4. What is a Semaphore in .NET, and how does it differ from a Mutex?

    Counting semaphores, System.Threading.Semaphore as a kernel object, named semaphores and platform limits, no thread affinity, SemaphoreFullException and use cases.

    Mid-Level Theory Synchronization Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world
  5. What is SemaphoreSlim, and how do you use it as an async lock or to throttle concurrent async work?

    SemaphoreSlim internals, WaitAsync with timeouts and cancellation, async mutual exclusion, throttling HTTP calls, non-reentrancy and release discipline.

    Mid-Level Coding Synchronization Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  6. What is SpinLock, and when (if ever) should you use it instead of lock?

    SpinLock and SpinWait, busy-waiting versus blocking, struct copying pitfalls, owner tracking and why most code should not use it.

    Senior Theory Synchronization Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  7. When would you use ReaderWriterLockSlim, and what are its pitfalls compared with lock or immutable snapshots?

    Read, write and upgradeable read locks, recursion policy, thread affinity, performance reality and lock-free alternatives for read-mostly data.

    Senior Theory Synchronization Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  8. What does the Interlocked class do, and how do you build a lock-free update with CompareExchange?

    Atomic Increment, Add, Exchange, CompareExchange, Read, And and Or; full fences; CAS loops; ABA and when lock-free is worth it.

    Senior Coding Synchronization Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  9. What does volatile mean in C#, and how do Volatile.Read and Volatile.Write differ from Interlocked?

    Compiler and CPU reordering, acquire and release semantics, the volatile keyword, Volatile class, x64 versus Arm64 memory models and what volatile does not guarantee.

    Senior Theory Synchronization Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world
  10. What are memory barriers, why do CPUs and compilers reorder memory operations, and how does .NET expose barriers?

    Store buffers and reordering, full versus half fences, Interlocked.MemoryBarrier, implicit barriers in locks and Interlocked, double-checked locking and MemoryBarrierProcessWide.

    Staff / Architect Theory Synchronization Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world

🌐 Sangam's Webring

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