static Span<int> CreateLengthOneSpanExample1(ref int i) {
var result = new Span<int>(ref i);
return result;
}
static Span<int> CreateLengthOneSpanExample2(ref int i) {
Span<int> result;
result = new Span<int>(ref i); // Fails to compile on this line
return result;
}
static Span<int> CreateLengthOneSpanExample3(ref int i) {
Span<int> result = stackalloc int[1];
result = new Span<int>(ref i);
return result; // Fails to compile on this line
}
Code snippet taken from "Complete C# Quick Reference - C# 11".