Memory<T> Struct
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Represents a contiguous region of memory.
generic <typename T>
public value class Memory : IEquatable<Memory<T>>
generic <typename T>
public value class Memory
public readonly struct Memory<T> : IEquatable<Memory<T>>
public readonly struct Memory<T>
type Memory<'T> = struct
Public Structure Memory(Of T)
Implements IEquatable(Of Memory(Of T))
Public Structure Memory(Of T)
- T
The type of items in the Memory<T>.
- Inheritance
- Implements
-
IEquatable<Memory<T>>
Like Span<T>, Memory<T>
represents a contiguous region of memory. Unlike Span<T>, however, Memory<T>
is not a ref struct. This means that Memory<T>
can be placed on the managed heap, whereas Span<T> cannot. 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.
It can be used across
await
andyield
boundaries.
In addition to Memory<T>
, you can use System.ReadOnlyMemory<T> to represent immutable or read-only memory.
Memory<T>(T[], Int32, Int32) |
Creates a new Memory<T> object that includes a specified number of elements of an array beginning at a specified index. |
Memory<T>(T[]) |
Creates a new Memory<T> object over the entirety of a specified array. |
Empty |
Returns an empty Memory<T> object. |
Is |
Indicates whether the current instance is empty. |
Length |
Gets the number of items in the current instance. |
Span |
Returns a span from the current instance. |
Copy |
Copies the contents of a Memory<T> object into a destination Memory<T> object. |
Equals(Memory<T>) |
Determines whether the specified Memory<T> object is equal to the current object. |
Equals(Object) |
Determines whether the specified object is equal to the current object. |
Get |
Returns the hash code for this instance. |
Pin() |
Creates a handle for the Memory<T> object. |
Slice(Int32, Int32) |
Forms a slice out of the current memory starting at a specified index for a specified length. |
Slice(Int32) |
Forms a slice out of the current memory that begins at a specified index. |
To |
Copies the contents from the memory into a new array. |
To |
Returns the string representation of this Memory<T> object. |
Try |
Copies the contents of the memory into a destination Memory<T> instance. |
Implicit(Array |
Defines an implicit conversion of an ArraySegment<T> object to a Memory<T> object. |
Implicit(Memory<T> to Read |
Defines an implicit conversion of a Memory<T> object to a ReadOnlyMemory<T> object. |
Implicit(T[] to Memory<T>) |
Defines an implicit conversion of an array to a Memory<T> object. |
Trim<T>(Memory<T>, T) |
Removes all leading and trailing occurrences of a specified element from a memory region. |
Trim<T>(Memory<T>, Read |
Removes all leading and trailing occurrences of a set of elements specified in a read-only span from a memory region. |
Trim |
Removes all trailing occurrences of a specified element from a character memory region. |
Trim |
Removes all trailing occurrences of a set of elements specified in a read-only span from a memory region. |
Trim |
Removes all leading occurrences of a specified element from a memory region. |
Trim |
Removes all leading occurrences of a set of elements specified in a read-only span from a memory region. |
Продукт | Версии |
---|---|
.NET | Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided) |
.NET Standard | 2.0 (package-provided), 2.1 |
Отзыв о .NET
.NET — это проект с открытым исходным кодом. Выберите ссылку, чтобы оставить отзыв: