What are concurrent collections in .NET?
Concurrent collections are thread-safe collection types designed for access by multiple threads.
C# interview questions covering concurrency, performance & design.
Open a question for the full answer, code and interview guidance.
Concurrent collections are thread-safe collection types designed for access by multiple threads.
SemaphoreSlim limits how many callers can enter a protected region concurrently. Unlike lock, it can allow more than one caller and supports asynchronous waiting through WaitAsync.
Interlocked provides atomic operations for simple shared variables without requiring a traditional lock.
A deadlock occurs when operations wait indefinitely for resources or each other in a cycle, so none can continue.
Thread safety means code behaves correctly when accessed concurrently by multiple threads.
Serialization converts an object's data into a format suitable for storage or transmission, such as JSON. Deserialization reconstructs an object representation from that format.
System.Text.Json is built into modern .NET and is optimized for performance, low allocations, and integration with ASP.NET Core. It is the default JSON serializer for current ASP.NET Core applications.
Span<T> is a stack-only type representing a contiguous region of memory. It can provide efficient slicing and processing of arrays, stack memory, strings through related read-only spans, and other buffers without allocating new objects for many operations.
StringBuilder is a mutable buffer designed for efficiently constructing strings through many modifications or concatenations.
Performance diagnosis should begin with measurement rather than random code changes.