Szerkesztés

Megosztás a következőn keresztül:


MemoryMarshal.AsMemory<T>(ReadOnlyMemory<T>) Method

Definition

Creates a Memory<T> instance from a ReadOnlyMemory<T>.

public:
generic <typename T>
 static Memory<T> AsMemory(ReadOnlyMemory<T> memory);
public static Memory<T> AsMemory<T> (ReadOnlyMemory<T> memory);
static member AsMemory : ReadOnlyMemory<'T> -> Memory<'T>
Public Shared Function AsMemory(Of T) (memory As ReadOnlyMemory(Of T)) As Memory(Of T)

Type Parameters

T

The type of items in the read-only memory buffer.

Parameters

memory
ReadOnlyMemory<T>

The read-only memory buffer.

Returns

A memory block that represents the same memory as the ReadOnlyMemory<T>.

Remarks

Caution

This method must be used with extreme caution. ReadOnlyMemory<T> is used to represent immutable data and other memory that is not meant to be written to. Memory<T> instances created by this method should not be written to. The purpose of this method is to allow variables typed as Memory<T> but only used for reading to store a ReadOnlyMemory<T>.

Applies to