Edit

Share via


ReadOnlyMemoryExtensions.AsBytes<T>(ReadOnlyMemory<T>) Method

Definition

Casts a ReadOnlyMemory<T> of one primitive type T to ReadOnlyMemory<T> of bytes.

public static ReadOnlyMemory<byte> AsBytes<T> (this ReadOnlyMemory<T> memory) where T : struct;
static member AsBytes : ReadOnlyMemory<'T (requires 'T : struct)> -> ReadOnlyMemory<byte> (requires 'T : struct)
<Extension()>
Public Function AsBytes(Of T As Structure) (memory As ReadOnlyMemory(Of T)) As ReadOnlyMemory(Of Byte)

Type Parameters

T

The type if items in the source ReadOnlyMemory<T>.

Parameters

memory
ReadOnlyMemory<T>

The source ReadOnlyMemory<T>, of type T.

Returns

A ReadOnlyMemory<T> of bytes.

Exceptions

Thrown if the Length property of the new ReadOnlyMemory<T> would exceed MaxValue.

Thrown when the data store of memory is not supported.

Applies to