Memory<T> Memory<T> Memory<T> Memory<T> Struct

定義

代表連續的記憶體區域。Represents a contiguous region of memory.

generic <typename T>
public value class Memory
public struct Memory<T>
type Memory<'T> = struct
Public Structure Memory(Of T)

類型參數

T

中的項目類型Memory<T>The type of items in the Memory<T>.

繼承

備註

像是Span<T>Memory<T>代表連續的記憶體區域。Like Span<T>, Memory<T> represents a contiguous region of memory. 不同於Span<T>,不過Memory<T>不是ref structUnlike Span<T>, however, Memory<T> is not a ref struct. 這表示Memory<T>而可放置在 managed 堆積,Span<T>無法。This means that Memory<T> can be placed on the managed heap, whereas Span<T> cannot. 如此一來,Memory<T>結構沒有相同的限制Span<T>執行個體。As a result, the Memory<T> structure does not have the same restrictions as a Span<T> instance. 特別之處在於:In particular:

  • 它可用來當做類別中的欄位。It can be used as a field in a class.

  • 可使用於awaityield界限。It can be used across await and yield boundaries.

除了Memory<T>,您可以使用System.ReadOnlyMemory<T>代表不可變或唯讀記憶體。In addition to Memory<T>, you can use System.ReadOnlyMemory<T> to represent immutable or read-only memory.

建構函式

Memory<T>(T[]) Memory<T>(T[]) Memory<T>(T[]) Memory<T>(T[])

在整個指定的陣列上建立新的 Memory<T> 物件。Creates a new Memory<T> object over the entirety of a specified array.

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

建立新的 Memory<T> 物件,其中包含開始於指定索引之陣列的指定項目數。Creates a new Memory<T> object that includes a specified number of elements of an array beginning at a specified index.

屬性

Empty Empty Empty Empty

傳回空的 Memory<T> 物件。Returns an empty Memory<T> object.

IsEmpty IsEmpty IsEmpty IsEmpty

指出目前的執行個體是否為空的。Indicates whether the current instance is empty.

Item[Range] Item[Range] Item[Range] Item[Range]
Length Length Length Length

取得目前執行個體中的項目數目。Gets the number of items in the current instance.

Span Span Span Span

傳回目前執行個體的範圍。Returns a span from the current instance.

方法

CopyTo(Memory<T>) CopyTo(Memory<T>) CopyTo(Memory<T>) CopyTo(Memory<T>)

Memory<T> 物件的內容複製到目的地 Memory<T> 物件。Copies the contents of a Memory<T> object into a destination Memory<T> object.

Equals(Memory<T>) Equals(Memory<T>) Equals(Memory<T>) Equals(Memory<T>)

判斷指定的 Memory<T> 物件是否等於目前的物件。Determines whether the specified Memory<T> object is equal to the current object.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

傳回這個執行個體的雜湊碼。Returns the hash code for this instance.

Pin() Pin() Pin() Pin()

建立 Memory<T> 物件的控制代碼。Creates a handle for the Memory<T> object.

Slice(Index) Slice(Index) Slice(Index) Slice(Index)
Slice(Int32) Slice(Int32) Slice(Int32) Slice(Int32)

從起始於指定索引的目前記憶體形成配量。Forms a slice out of the current memory that begins at a specified index.

Slice(Range) Slice(Range) Slice(Range) Slice(Range)
Slice(Int32, Int32) Slice(Int32, Int32) Slice(Int32, Int32) Slice(Int32, Int32)

從起始於指定索引之指定長度的目前記憶體形成配量。Forms a slice out of the current memory starting at a specified index for a specified length.

ToArray() ToArray() ToArray() ToArray()

將記憶體的內容複製到新的陣列。Copies the contents from the memory into a new array.

ToString() ToString() ToString() ToString()

傳回此 Memory<T> 物件的字串表示。Returns the string representation of this Memory<T> object.

TryCopyTo(Memory<T>) TryCopyTo(Memory<T>) TryCopyTo(Memory<T>) TryCopyTo(Memory<T>)

將記憶體的內容複製到目的地 Memory<T> 執行個體。Copies the contents of the memory into a destination Memory<T> instance.

運算子

Implicit(T[] to Memory<T>) Implicit(T[] to Memory<T>) Implicit(T[] to Memory<T>) Implicit(T[] to Memory<T>)

定義從陣列到 Memory<T> 物件的隱含轉換。Defines an implicit conversion of an array to a Memory<T> object.

Implicit(ArraySegment<T> to Memory<T>) Implicit(ArraySegment<T> to Memory<T>) Implicit(ArraySegment<T> to Memory<T>) Implicit(ArraySegment<T> to Memory<T>)

定義從 ArraySegment<T> 物件到 Memory<T> 物件的隱含轉換。Defines an implicit conversion of an ArraySegment<T> object to a Memory<T> object.

Implicit(Memory<T> to ReadOnlyMemory<T>) Implicit(Memory<T> to ReadOnlyMemory<T>) Implicit(Memory<T> to ReadOnlyMemory<T>) Implicit(Memory<T> to ReadOnlyMemory<T>)

定義從 Memory<T> 物件到 ReadOnlyMemory<T> 物件的隱含轉換。Defines an implicit conversion of a Memory<T> object to a ReadOnlyMemory<T> object.

適用於