Examples from Chapter 18 (Memory Efficiency) of Programming C# 12.0 (O'Reilly).
- Example 3. Iterating over a Span<int>
- Example 4. Passing an int[] as a ReadOnlySpan<int>
- Example 5. Array syntax implicitly creating a
ReadOnlySpan<int>
directly - Example 5. Passing a stack-allocated array as a ReadOnlySpan<int>
- Example 6. Array syntax examples that defeat the no-array optimization
- Example 7. Passing a stack-allocated array as a
ReadOnlySpan<int>
- Example 8. Using collection expressions with spans
- Example 9. Parsing integers in a string using Span<char>
- Example 10. Using a collection builder
- Example 11. Using a span with a list pattern
- Example 12. Span as input to a string constant pattern
- Example 13. Type with a
ref
field - Example 14. Using a type with a
ref
field - Example 15. A method that captures a
ref
- Example 16. Attempting to enable a
ref
to outlive its target's stack frame - Example 17. Attempting to enable a
ref
to outlive its target's stack frame - Example 18. Code C# thinks might be attempting to enable a
ref
to outlive its target's stack frame - Example 19. Declaring non-capture of a
ref