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
span
ExSpan<T>The source slice, of type
T
(T
类型的源切片).
Returns
Type Parameters
T
The element type (元素的类型).
Exceptions
- ArgumentException
Thrown when
T
contains 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
span
ReadOnlyExSpan<T>The source slice, of type
T
(T
类型的源切片).
Returns
Type Parameters
T
The element type (元素的类型).
Exceptions
- ArgumentException
Thrown when
T
contains pointers.- OverflowException
Thrown if the Length property of the new ExSpan would exceed MaxValue.