Επεξεργασία

Κοινή χρήση μέσω


MemoryMarshal.Write<T>(Span<Byte>, T) Method

Definition

Writes a structure of type T into a span of bytes.

public:
generic <typename T>
 where T : value class static void Write(Span<System::Byte> destination, T % value);
public static void Write<T> (Span<byte> destination, ref T value) where T : struct;
public static void Write<T> (Span<byte> destination, in T value) where T : struct;
static member Write : Span<byte> * 'T -> unit (requires 'T : struct)
Public Shared Sub Write(Of T As Structure) (destination As Span(Of Byte), ByRef value As T)

Type Parameters

T

The type of the structure.

Parameters

destination
Span<Byte>

The span of bytes to contain the structure.

value
T

The structure to be written to the span.

Exceptions

T contains managed object references.

destination is too small to contain value.

Remarks

T cannot contain managed object references. The Write method performs this check at runtime and throws ArgumentException if the check fails.

Caution

This method copies raw binary data from the original span, including any private instance fields and other implementation details of type T. Callers should ensure that their code is resilient to changes in the internal layout of T.

Applies to