Skip to main content

Span, Memory, and Ref Structs

Span, Memory, and ref structs represent a fundamental shift in how modern C# developers approach performance. While traditional arrays and lists allocate on the managed heap, these constructs enable you to work with contiguous memory—on the stack, in unmanaged buffers, or from existing arrays—without triggering garbage collection. This series takes you from first principles through production patterns.

Over eight years (2018–2026), Span has evolved from a curiosity into the backbone of high-throughput systems. Microsoft's own runtime, the ASP.NET Core framework, and every high-performance library now rely on these primitives. By mastering them, you'll unlock the ability to build parsers, serializers, and network handlers that process terabytes of data with near-zero overhead.

This series is designed for intermediate C# developers ready to level up. You'll need solid knowledge of arrays, generics, and method signatures, but we'll teach everything about memory layout, stack safety, and the subtle rules that govern ref types. Each article is standalone but builds on the previous; read them in order for a cohesive mental model.

Articles in this series