// Invalid: Ref struct types can not be the element type of an array
// Because arrays are stored on the heap
static readonly Span<int>[] _intSpanArray;
// Invalid: Ref struct types can not be fields or properties of any class or struct except ref structs
// Because class instances are stored on the heap, and struct instances may be boxed (i.e. a copy stored on the heap)
public Span<int> SomeSpan { get; set; }
// Invalid: Ref struct types can not implement interfaces
// Because using them as their interface type would always require boxing
readonly ref struct MyRefStruct : IEquatable<MyRefStruct> { }
// Invalid: Ref struct types can not be cast to object (or boxed in any way)
// Because boxed copies of structs are stored on the heap
var boxedSpan = (object) mySpan;
// Invalid: Ref struct types can not be type arguments
// Because usage of elements can not currently be verified as valid (and some usages will never be valid, i.e. List<T>)
var list = new List<Span<int>>();
// Invalid: Ref struct types can not be closed-over (captured) by a lambda/anonymous function
// Because captured variables must be stored in a heap object so that they're still available when the lambda is executed
var filtered = someEnumerable.Where(x => x[0] == mySpan[0]);
// Invalid: Ref struct types can not be used in an async method (locals or parameters)
// Because locals in async methods may be stored in heap objects to become part of the internal state machine built by the compiler
async Task SomeMethodAsync(Span<int> mySpan) { /* ... */ }
Code snippet taken from "Complete C# Quick Reference - C# 7".