Well, there's the primary benefits: I can avoid making copies of arrays, and I am spared the burden of passing startIndex and length everywhere. The secondary benefit is huge in game dev: a span can reference managed or unmanaged memory! So, regardless of whether the underlying data came from a new byte[...] in C# or a malloc in C (common in my native libraries like SQLite), I can write nice clean C# code to interact with it.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Well, there's the primary benefits: I can avoid making copies of arrays, and I am spared the burden of passing
startIndex
andlength
everywhere. The secondary benefit is huge in game dev: a span can reference managed or unmanaged memory! So, regardless of whether the underlying data came from anew byte[...]
in C# or amalloc
in C (common in my native libraries like SQLite), I can write nice clean C# code to interact with it.