MemoryMarshal 類別

定義

提供方法來與 Memory<T>ReadOnlyMemory<T>Span<T>ReadOnlySpan<T> 交互操作。Provides methods to interoperate with Memory<T>, ReadOnlyMemory<T>, Span<T>, and ReadOnlySpan<T>.

public ref class MemoryMarshal abstract sealed
public static class MemoryMarshal
type MemoryMarshal = class
Public Class MemoryMarshal
繼承
MemoryMarshal

方法

AsBytes<T>(ReadOnlySpan<T>)

將一個簡單型別 ReadOnlySpan<T>T 轉換成 ReadOnlySpan<Byte>Casts a ReadOnlySpan<T> of one primitive type, T, to a ReadOnlySpan<Byte>.

AsBytes<T>(Span<T>)

將一個簡單型別 Span<T>T 轉換成 Span<Byte>Casts a Span<T> of one primitive type, T, to a Span<Byte>.

AsMemory<T>(ReadOnlyMemory<T>)

Memory<T> 建立 ReadOnlyMemory<T> 執行個體。Creates a Memory<T> instance from a ReadOnlyMemory<T>.

AsRef<T>(ReadOnlySpan<Byte>)

將唯讀範圍的位元組重新解譯為 T 類型結構的唯讀參考。Reinterprets a read-only span of bytes as a read-only reference to the structure of type T.

AsRef<T>(Span<Byte>)

將位元組範圍重新解譯為 T 類型結構的參考。Reinterprets a span of bytes as a reference to the structure of type T.

Cast<TFrom,TTo>(ReadOnlySpan<TFrom>)

將一個簡單型別的唯讀範圍轉換為另一個簡單型別的唯讀範圍。Casts a read-only span of one primitive type to a read-only span of another primitive type.

Cast<TFrom,TTo>(Span<TFrom>)

將一個簡單型別的範圍轉換為另一個簡單型別的範圍。Casts a span of one primitive type to a span of another primitive type.

CreateFromPinnedArray<T>(T[], Int32, Int32)

在預先定義的目標陣列上建立新的記憶體緩衝區,從 start 索引開始,並包含 length 個項目。Creates a new memory buffer over the portion of the pre-pinned target array beginning at the start index and consisting of length items.

CreateReadOnlySpan<T>(T, Int32)

在一般受控物件上建立新的唯讀範圍。Creates a new read-only span over a portion of a regular managed object.

CreateSpan<T>(T, Int32)

在一般受控物件上建立新的範圍。Creates a new span over a portion of a regular managed object.

GetReference<T>(ReadOnlySpan<T>)

傳回唯讀範圍索引位置為 0 的元素參考。Returns a reference to the element of the read-only span at index 0.

GetReference<T>(Span<T>)

傳回範圍索引位置為 0 的元素參考。Returns a reference to the element of the span at index 0.

Read<T>(ReadOnlySpan<Byte>)

讀取型別結構Reads a structure of type 超出位元組的唯讀範圍。out of a read-only span of bytes.

ToEnumerable<T>(ReadOnlyMemory<T>)

建立指定唯讀記憶體緩衝區的 IEnumerable<T> 檢視。Creates an IEnumerable<T> view of the given read-only memory buffer.

TryGetArray<T>(ReadOnlyMemory<T>, ArraySegment<T>)

嘗試從基礎記憶體緩衝區取得陣列區段。Tries to get an array segment from the underlying memory buffer. 傳回值指出作業是否成功。The return value indicates the success of the operation.

TryGetMemoryManager<T,TManager>(ReadOnlyMemory<T>, TManager)

嘗試從基礎唯讀記憶體緩衝區擷取 MemoryManager<T>Tries to retrieve a MemoryManager<T> from the underlying read-only memory buffer.

TryGetMemoryManager<T,TManager>(ReadOnlyMemory<T>, TManager, Int32, Int32)

嘗試從基礎唯讀記憶體緩衝區擷取 MemoryManager<T>、開始索引和長度。Tries to retrieve a MemoryManager<T>, start index, and length from the underlying read-only memory buffer.

TryGetString(ReadOnlyMemory<Char>, String, Int32, Int32)

嘗試從 System.ReadOnlyMemory<Char> 取得基礎字串。Tries to get the underlying string from a System.ReadOnlyMemory<Char>.

TryRead<T>(ReadOnlySpan<Byte>, T)

嘗試從位元組唯讀範圍中讀取類型 T 的結構。Tries to read a structure of type T from a read-only span of bytes.

TryWrite<T>(Span<Byte>, T)

嘗試將 T 類型的結構寫入位元組範圍。Tries to write a structure of type T into a span of bytes.

Write<T>(Span<Byte>, T)

將類型 T 的結構寫入位元組範圍。Writes a structure of type T into a span of bytes.

適用於