<PackageReference Include="System.Memory" Version="4.6.0" />

Memory<T>

public struct Memory<T>
Memory represents a contiguous region of arbitrary memory similar to Span<T>. Unlike Span<T>, it is not a byref-like type.
public static Memory<T> Empty { get; }

Returns an empty Memory<T>

public bool IsEmpty { get; }

Returns true if Length is 0.

public int Length { get; }

The number of items in the memory.

public Span<T> Span { get; }

Returns a span from the memory.

public Memory(T[] array)

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

public Memory(T[] array, int start, int length)

Creates a new memory over the portion of the target array beginning at 'start' index and ending at 'end' index (exclusive).

public static Memory<T> op_Implicit(T[] array)

Defines an implicit conversion of an array to a Memory<T>

public static Memory<T> op_Implicit(ArraySegment<T> segment)

Defines an implicit conversion of a ArraySegment<T> to a Memory<T>

public static ReadOnlyMemory<T> op_Implicit(Memory<T> memory)

Defines an implicit conversion of a Memory<T> to a ReadOnlyMemory<T>

public void CopyTo(Memory<T> destination)

Copies the contents of the memory into the destination. If the source and destination overlap, this method behaves as if the original values are in a temporary location before the destination is overwritten. The Memory to copy items into.Thrown when the destination is shorter than the source.

public bool Equals(Memory<T> other)

Returns true if the memory points to the same array and has the same length. Note that this does *not* check to see if the *contents* are equal.

public MemoryHandle Pin()

Creates a handle for the memory. The GC will not move the memory until the returned MemoryHandle is disposed, enabling taking and using the memory's address. An instance with nonprimitive (non-blittable) members cannot be pinned.

public Memory<T> Slice(int start)

Forms a slice out of the given memory, beginning at 'start'.

public Memory<T> Slice(int start, int length)

Forms a slice out of the given memory, beginning at 'start', of given length

public T[] ToArray()

Copies the contents from the memory into a new array. This heap allocates, so should generally be avoided, however it is sometimes necessary to bridge the gap with APIs written in terms of arrays.

public bool TryCopyTo(Memory<T> destination)

Copies the contents of the memory into the destination. If the source and destination overlap, this method behaves as if the original values are in a temporary location before the destination is overwritten. If the destination is shorter than the source, this method return false and no data is written to the destination.