Spans are a new hot topic in C# when optimizing CPU-bound code. But did you know that most of the span's incredible performance comes from the critical constraint put upon it. The span can only exist on the stack.
And so there can never exist an array of spans. Nor any other collection of spans for that matter.
You cannot capture it in a closure.
A span cannot be boxed, so forget assigning it to a reference.
A class cannot have a field of type span.
What can it be, then? Well, it is possible to hold a common variable which is a span, obviously.
And you can also include it as a field inside other ref structs. Any ref struct must entirely reside on stack, so this is fine.
It can also be a method's argument. Arguments are passed via stack anyway. It can be the method's return type as well.
Video courses:
Beginning Object-oriented Programming with C# ► [ Ссылка ]
Collections and Generics in C# ► [ Ссылка ]
Making Your C# Code More Object-oriented ► [ Ссылка ]
Other courses at Pluralsight ► [ Ссылка ]
Other courses at Udemy ► [ Ссылка ]
Additional videos:
The Fastest Way to Modify a List in C# ► [ Ссылка ]
Coding with GitHub Copilot - Beginner to Master ► [ Ссылка ]
Want to Start with DDD? Try Ubiquitous Language First! ► [ Ссылка ]
Using C# Record Types ► [ Ссылка ]
Covariance and Contravariance in C# ► [ Ссылка ]
How do Virtual Functions Work? ► [ Ссылка ]
Practical Design playlist at YouTube ► [ Ссылка ]
Ещё видео!