MemoryMarshal.Read<T>(ReadOnlySpan<Byte>) Method

Definition

Reads a structure of type out of a read-only span of bytes.

public:
generic <typename T>
 where T : value class static T Read(ReadOnlySpan<System::Byte> source);
public static T Read<T> (ReadOnlySpan<byte> source) where T : struct;
static member Read : ReadOnlySpan<byte> -> 'T (requires 'T : struct)
Public Shared Function Read(Of T As Structure) (source As ReadOnlySpan(Of Byte)) As T

Type Parameters

T

The type of the item to retrieve from the read-only span.

Parameters

source
ReadOnlySpan<Byte>

A read-only span.

Returns

T

The structure retrieved from the read-only span.

Exceptions

T contains references or pointers.

source is smaller than T.

Remarks

T cannot contain pointers or references. It is checked at runtime in order to preserve type safety.

Applies to