Method AsBytes
AsBytes<T>(ExSpan<T>)
Casts a ExSpan of one primitive type T to ExSpan of bytes.
That type may not contain pointers or references. This is checked at runtime in order to preserve type safety
(将一个基元类型T的ExSpan 转换为字节的ExSpan. 该类型不能包含指针或引用. 它会在运行时检查这一点, 以保护类型安全).
public static ExSpan<byte> AsBytes<T>(ExSpan<T> span) where T : struct
Parameters
spanExSpan<T>The source slice, of type
T(T类型的源切片).
Returns
Type Parameters
TThe element type (元素的类型).
Exceptions
- ArgumentException
Thrown when
Tcontains pointers.- OverflowException
Thrown if the Length property of the new ExSpan would exceed MaxValue.
AsBytes<T>(ReadOnlyExSpan<T>)
Casts a ReadOnlyExSpan of one primitive type T to ReadOnlyExSpan of bytes.
That type may not contain pointers or references. This is checked at runtime in order to preserve type safety.
(将一个基元类型T的ExSpan 转换为字节的ReadOnlyExSpan. 该类型不能包含指针或引用. 它会在运行时检查这一点, 以保护类型安全).
public static ReadOnlyExSpan<byte> AsBytes<T>(ReadOnlyExSpan<T> span) where T : struct
Parameters
spanReadOnlyExSpan<T>The source slice, of type
T(T类型的源切片).
Returns
Type Parameters
TThe element type (元素的类型).
Exceptions
- ArgumentException
Thrown when
Tcontains pointers.- OverflowException
Thrown if the Length property of the new ExSpan would exceed MaxValue.