Skip to content
Free public beta until December 4, 2026: every course is open, no card needed. After that, the first chapter of each course stays free and full access is a one-time $39 ($19 for up to 100 founding members chosen for helpful feedback). Your progress is kept. How the beta works

ref struct

A struct that may live only on the stack, like Span.

A ref struct cannot be boxed, stored in a field of a class, captured by a lambda, or kept alive across await or yield; the compiler enforces this so it can safely refer to stack memory.

Examples

  • Span<T> is a ref struct, so it can't be a field of a class or be kept across an await.

Read the full section →