Pages

Topics

Tools

↑↓navigate↵openescclose

All syntax guides

Short, practical guides on programming syntax, language fundamentals, and the tools developers reach for every day.

3,980 guides across 14 topics

Topics

Latest guides

A visual metaphor for C# IDisposable showing a resource handle being released and cleaned up.
C#

C# IDisposable: The Dispose Pattern Explained

c# idisposable: Learn how to implement IDisposable correctly in C#, use the using statement, and avoid common resource leaks.

IDisposableDispose Patternusing StatementResource Management
A clean diagram illustrating the C# dispose pattern flow from the Dispose method through managed and unmanaged resource cleanup paths.
C#

Implementing the C# Dispose Pattern

Learn how to implement the C# dispose pattern correctly, covering IDisposable, finalizers, using statements, async disposal, and common failure modes.

dispose patternIDisposableresource cleanupgarbage collection
Illustration of a C# SemaphoreSlim gate allowing a limited number of concurrent threads through while others wait.
C#

Using C# SemaphoreSlim to Limit Concurrent Access

Learn how C# SemaphoreSlim limits concurrent access to shared resources, with async waiting, cancellation, and practical throttling examples.

SemaphoreSlimConcurrencyAsyncThreading
Illustration of a concurrent stack with multiple threads pushing and popping items safely
C#

C# ConcurrentStack: Thread-Safe LIFO Collection

Learn how to use C# ConcurrentStack for thread-safe LIFO operations: Push, TryPop, TryPeek, bulk methods, and the performance tradeoffs to consider.

C#ConcurrencyThread-SafeCollections
Illustration of a thread-safe FIFO queue in C# with multiple producer and consumer threads.
C#

Using C# ConcurrentQueue for Thread-Safe FIFO Work

Understand how to use C# ConcurrentQueue<T> for thread-safe FIFO operations: core methods, enumeration, performance, and common pitfalls.

ConcurrentQueueThread-SafetyC# CollectionsProducer-Consumer
A visual representation of a ConcurrentDictionary with multiple threads accessing it safely, showing atomic operations and locking segments.
C#

Using C# ConcurrentDictionary for Thread-Safe Collections

Learn how to use C# ConcurrentDictionary for thread-safe operations, including atomic methods, performance tradeoffs, and when to choose it over other approaches.

ConcurrencyThread SafetyDictionaryC# Collections
Illustration of C# concurrent collections representing thread-safe data structures with multiple threads accessing a shared collection.
C#

C# Concurrent Collections: Choosing the Right Thread-Safe Collection

Learn how to choose and use C# concurrent collections such as ConcurrentDictionary, ConcurrentQueue, ConcurrentStack, ConcurrentBag, and BlockingCollection, including code examples and common pitfalls.

C# ConcurrencyThread-Safe CollectionsSystem.Collections.ConcurrentProducer-Consumer
Illustration of multiple parallel threads each holding an isolated data container, representing ThreadLocal storage in C#.
C#

Using ThreadLocal<T> in C# for Per-Thread State

Learn how C# ThreadLocal<T> provides isolated per-thread state, when to use it instead of ThreadStatic or AsyncLocal, and how it affects memory and disposal.

ThreadLocalC# ConcurrencyThread SafetyAsyncLocal
A visual metaphor for the C# volatile keyword showing a memory barrier between threads and a shared field.
C#

C# volatile: Semantics and Practical Use

Understand what C# volatile does, when to use it, and its limits. Practical examples show correct usage and common pitfalls.

volatilememory modelthread safetyconcurrency
Diagram showing multiple threads performing an atomic increment on a single shared counter using C# Interlocked
C#

C# Interlocked: Atomic Operations Without Locks

c# interlocked: Learn how C# Interlocked provides atomic operations for thread-safe counters and lock-free updates without explicit locking.

Thread SafetyAtomic OperationsConcurrency.NET