Advanced C#
Q69 / 100

What is a ref struct in C# and what restrictions apply?

Correct! Well done.

Incorrect.

The correct answer is B) A struct that can only exist on the stack or in registers, cannot be boxed, stored in fields of regular types, or captured by lambdas

B

Correct Answer

A struct that can only exist on the stack or in registers, cannot be boxed, stored in fields of regular types, or captured by lambdas

Explanation

ref structs (Span<T>, ReadOnlySpan<T>) cannot be stored on the heap. This enables the runtime to guarantee their lifetime without GC tracking.

Progress
69/100