<PackageReference Include="System.Memory" Version="4.4.0-preview1-25305-02" />

Span<T>

public struct Span<T>
Span represents a contiguous region of arbitrary memory. Unlike arrays, it can point to either managed or native memory, or to memory allocated on the stack. It is type- and memory-safe.
public static Span<T> Empty { get; }

Returns a 0-length span whose base is the null pointer.

public bool IsEmpty { get; }

Returns true if Length is 0.

public ref T this[int index] { get; }

Returns a reference to specified element of the Span.

public int Length { get; }

The number of items in the span.

public Span(T[] array)

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

public Span(T[] array, int start)

Creates a new span over the portion of the target array beginning at 'start' index and covering the remainder of the array.

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

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

public Span(Void* pointer, int length)

Creates a new span over the target unmanaged buffer. Clearly this is quite dangerous, because we are creating arbitrarily typed T's out of a void*-typed block of memory. And the length is not checked. But if this creation is correct, then all subsequent uses are correct.

public static Span<T> DangerousCreate(object obj, ref T objectData, int length)

Create a new span over a portion of a regular managed object. This can be useful if part of a managed object represents a "fixed array." This is dangerous because neither the length is checked, nor obj being null, nor the fact that "rawPointer" actually lies within obj.

public static bool op_Equality(Span<T> left, Span<T> right)

Returns true if left and right point at the same memory and have the same length. Note that this does *not* check to see if the *contents* are equal.

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

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

public static Span<T> op_Implicit(ArraySegment<T> arraySegment)

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

public static ReadOnlySpan<T> op_Implicit(Span<T> span)

Defines an implicit conversion of a Span<T> to a ReadOnlySpan<T>

public static bool op_Inequality(Span<T> left, Span<T> right)

Returns false if left and right point at the same memory and have the same length. Note that this does *not* check to see if the *contents* are equal.

public void Clear()

Clears the contents of this span.

public void CopyTo(Span<T> destination)

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

Returns a reference to the 0th element of the Span. If the Span is empty, returns a reference to the location where the 0th element would have been stored. Such a reference can be used for pinning but must never be dereferenced.

public void Fill(T value)

Fills the contents of this span with the given value.

public Span<T> Slice(int start)

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

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

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

public T[] ToArray()

Copies the contents of this span 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(Span<T> destination)

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