Get Memory<T>/ReadOnlyMemory<T> from multidimensional array of T. #106605
-
There is no way to retrieve a Memory or ReadOnlyMemory from a non-unidimensional array, even though multidimensional arrays are stored in a contiguous memory region. This should be possible since multidimensional arrays are stored in contiguous memory. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
There lacks a way to represent "array of any dimensions of T", or With unsafe code, this can be achieved by: MemoryMarshal.CreateSpan(ref Unsafe.As<byte, T>(ref MemoryMarshal.GetArrayDataReference(array)), array.Length); For |
Beta Was this translation helpful? Give feedback.
It's likely beyond the scope of
MemoryExtensions
as it require non-trivial wrapping. And also,Range
doesn't fit naturally with md array.