MemoryExtensions.AsBytes<T>(Memory<T>) Method

Definition

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

C#
public static Memory<byte> AsBytes<T> (this Memory<T> memory) where T : struct;

Type Parameters

T

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

Parameters

memory
Memory<T>

The source Memory<T>, of type T.

Returns

A Memory<T> of bytes.

Exceptions

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

Thrown when the data store of memory is not supported.

Applies to

Produit Versions
Windows Community Toolkit 7.0.0