ReadOnlyMemory<T> ReadOnlyMemory<T> ReadOnlyMemory<T> ReadOnlyMemory<T> Struct

Definition

Represents a contiguous region of memory, similar to ReadOnlySpan<T>. Unlike ReadOnlySpan<T>, it is not a byref-like type.

generic <typename T>
public value class ReadOnlyMemory : IEquatable<ReadOnlyMemory<T>>
public struct ReadOnlyMemory<T> : IEquatable<ReadOnlyMemory<T>>
type ReadOnlyMemory<'T> = struct
Public Structure ReadOnlyMemory(Of T)
Implements IEquatable(Of ReadOnlyMemory(Of T))

Type Parameters

T

The object type from which the contiguous region of memory will be read.

Inheritance
ReadOnlyMemory<T>ReadOnlyMemory<T>ReadOnlyMemory<T>ReadOnlyMemory<T>
Implements

Constructors

ReadOnlyMemory<T>(T[]) ReadOnlyMemory<T>(T[]) ReadOnlyMemory<T>(T[]) ReadOnlyMemory<T>(T[])

Creates a new memory region over the entirety of the target array.

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

Creates a new memory region over the portion of the target array beginning at a specified position and including a specified number of elements.

Properties

Empty Empty Empty Empty

Gets an empty ReadOnlyMemory<T>.

IsEmpty IsEmpty IsEmpty IsEmpty

Gets a value that indicates whether this read-only memory region is empty.

Length Length Length Length

Gets the number of items in the memory region.

Span Span Span Span

Gets a span from the memory region.

Methods

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

Copies the contents of the read-only memory region into a destination memory region.

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

Determines whether the specified object is equal to the current read-only memory region.

Equals(ReadOnlyMemory<T>) Equals(ReadOnlyMemory<T>) Equals(ReadOnlyMemory<T>) Equals(ReadOnlyMemory<T>)

Determines whether the current instance and a specified ReadOnlyMemory<T> objects are equal.

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

Returns the hash code for this ReadOnlyMemory<T>.

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

Creates a handle for the memory.

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

Forms a slice out of the given memory region, beginning at a specified poisition and continuing to its end.

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

Forms a slice out of the given memory region starting at start position for length elements.

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

Copies the contents from the memory region into a new array.

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

Returns the string representation of this read-only memory instance.

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

Tries to copy the contents of the readonly-only memory into the destination and returns a value that indicates whether the copy operation succeeded.

Operators

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

Defines an implicit conversion of a ArraySegment<T> to a ReadOnlyMemory<T>.

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

Defines an implicit conversion of an array to a ReadOnlyMemory<T>.

Extension Methods

Trim<T>(ReadOnlyMemory<T>, T) Trim<T>(ReadOnlyMemory<T>, T) Trim<T>(ReadOnlyMemory<T>, T) Trim<T>(ReadOnlyMemory<T>, T)

Removes all leading and trailing occurrences of a specified element from a read-only memory region.

Trim<T>(ReadOnlyMemory<T>, ReadOnlySpan<T>) Trim<T>(ReadOnlyMemory<T>, ReadOnlySpan<T>) Trim<T>(ReadOnlyMemory<T>, ReadOnlySpan<T>) Trim<T>(ReadOnlyMemory<T>, ReadOnlySpan<T>)

Removes all leading and trailing occurrences of a set of elements specified in a read-only span from a read-only memory region.

TrimEnd<T>(ReadOnlyMemory<T>, T) TrimEnd<T>(ReadOnlyMemory<T>, T) TrimEnd<T>(ReadOnlyMemory<T>, T) TrimEnd<T>(ReadOnlyMemory<T>, T)

Removes all trailing occurrences of a specified element from a read-only memory region.

TrimEnd<T>(ReadOnlyMemory<T>, ReadOnlySpan<T>) TrimEnd<T>(ReadOnlyMemory<T>, ReadOnlySpan<T>) TrimEnd<T>(ReadOnlyMemory<T>, ReadOnlySpan<T>) TrimEnd<T>(ReadOnlyMemory<T>, ReadOnlySpan<T>)

Removes all trailing occurrences of a set of elements specified in a read-only span from a read-only memory region.

TrimStart<T>(ReadOnlyMemory<T>, T) TrimStart<T>(ReadOnlyMemory<T>, T) TrimStart<T>(ReadOnlyMemory<T>, T) TrimStart<T>(ReadOnlyMemory<T>, T)

Removes all leading occurrences of a specified element from a memory region.

TrimStart<T>(ReadOnlyMemory<T>, ReadOnlySpan<T>) TrimStart<T>(ReadOnlyMemory<T>, ReadOnlySpan<T>) TrimStart<T>(ReadOnlyMemory<T>, ReadOnlySpan<T>) TrimStart<T>(ReadOnlyMemory<T>, ReadOnlySpan<T>)

Removes all leading occurrences of a set of elements specified in a read-only span from a memory region.

Applies to