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 结构Unlike Span<T>, however, Memory<T> is not a ref struct. 这意味着Memory<T>而可以放置在托管堆上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.

适用于