3 ms·
>you can avoid heap allocations but that would be unidiomatic AFAIK until recently (with the introduction of the Span<T> types), the only way to avoid heap all
by HideousKojima 5y ago
>you can avoid heap allocations but that would be unidiomatic
AFAIK until recently (with the introduction of the Span<T> types), the only way to avoid heap allocations for arrays or any other kind of collections in C# was with stackalloc, which is unsafe.
- notanaverageman 5y agoYou still have to use stackalloc to allocate on stack. With Span<T> you don’t have to use the unsafe keyword and you can pass the allocated array to other functions easily.