ReadOnlySpanExtensions.AsBytes<T>(ReadOnlySpan<T>) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Casts a ReadOnlySpan<T> of one primitive type T
to ReadOnlySpan<T> of bytes.
That type may not contain pointers or references. This is checked at runtime in order to preserve type safety.
public static ReadOnlySpan<byte> AsBytes<T> (this ReadOnlySpan<T> span) where T : struct;
static member AsBytes : ReadOnlySpan<'T (requires 'T : struct)> -> ReadOnlySpan<byte> (requires 'T : struct)
<Extension()>
Public Function AsBytes(Of T As Structure) (span As ReadOnlySpan(Of T)) As ReadOnlySpan(Of Byte)
Type Parameters
- T
The type if items in the source ReadOnlySpan<T>.
Parameters
- span
- ReadOnlySpan<T>
The source slice, of type T
.
Returns
A ReadOnlySpan<T> of bytes.
Exceptions
Thrown when T
contains pointers.
Thrown if the Length property of the new ReadOnlySpan<T> would exceed MaxValue.