Span<T> Span<T> Span<T> Span<T> Struct

Definition

Provides a type- and memory-safe representation of a contiguous region of arbitrary memory.

generic <typename T>
public value class Span
public struct Span<T>
type Span<'T> = struct
Public Structure Span(Of T)
Type Parameters
T

The type of items in the Span<T>.

Inheritance

Remarks

Span<T> is a ref struct that is allocated on the stack rather than on the managed heap. Ref struct types have a number of restrictions to ensure that they cannot be promoted to the managed heap, including that they can't be boxed and they can't be assigned to variables of type Object, dynamic, and to any interface type.

A Span<T> instance is often used to hold the elements of an array or a portion of an array. Unlike an array, however, a Span<T> instance can point to managed memory, native memory, or memory managed on the stack.

Constructors

Span<T>(T[]) Span<T>(T[]) Span<T>(T[]) Span<T>(T[])

Creates a new Span<T> object over the entirety of a specified array.

Span<T>(Void*, Int32) Span<T>(Void*, Int32) Span<T>(Void*, Int32) Span<T>(Void*, Int32)

Creates a new Span<T> object from a specified number of bytes starting at a specified memory address.

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

Creates a new Span<T> object from a specified array starting at a specifed index position and continuing to the end of the array.

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

Creates a new Span<T> object that includes a specified number of elements of an array starting at a specified index.

Properties

Empty Empty Empty Empty

Returns an empty Span<T> object.

IsEmpty IsEmpty IsEmpty IsEmpty

Returns a value that indicates whether the current Span<T> is empty.

Item[Int32] Item[Int32] Item[Int32] Item[Int32]

Gets or sets the element at the specified zero-based index.

Length Length Length Length

Returns the length of the current span.

Methods

Clear() Clear() Clear() Clear()

Clears the contents of this Span<T> object.

CopyTo(Span<T>) CopyTo(Span<T>) CopyTo(Span<T>) CopyTo(Span<T>)

Copies the contents of this Span<T> into a destination Span<T>.

DangerousCreate(Object, T, Int32) DangerousCreate(Object, T, Int32) DangerousCreate(Object, T, Int32) DangerousCreate(Object, T, Int32)
DangerousGetPinnableReference() DangerousGetPinnableReference() DangerousGetPinnableReference() DangerousGetPinnableReference()
Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Calls to this method are not supported.

Fill(T) Fill(T) Fill(T) Fill(T)

Fills the elements of this span with a specified value.

GetEnumerator() GetEnumerator() GetEnumerator() GetEnumerator()

Returns an enumerator for this Span<T>.

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

Throws a NotSupportedException.

GetPinnableReference() GetPinnableReference() GetPinnableReference() GetPinnableReference()

Returns a reference to the element of the Span<T> at index zero.

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

Forms a slice out of the current span that begins at a specified index.

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

Forms a slice out of the current span starting at a specified index for a specified length.

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

Copies the contents of this span into a new array.

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

Returns the string representation of this Span<T> object.

TryCopyTo(Span<T>) TryCopyTo(Span<T>) TryCopyTo(Span<T>) TryCopyTo(Span<T>)

Attempts to copy the current Span<T> to a destination Span<T> and returns a value that indicates whether the copy operation succeeded.

Operators

Equality(Span<T>, Span<T>) Equality(Span<T>, Span<T>) Equality(Span<T>, Span<T>) Equality(Span<T>, Span<T>)

Returns a value that indicates whether two Span<T> objects are equal.

Implicit(Span<T> to ReadOnlySpan<T>) Implicit(Span<T> to ReadOnlySpan<T>) Implicit(Span<T> to ReadOnlySpan<T>) Implicit(Span<T> to ReadOnlySpan<T>)

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

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

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

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

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

Inequality(Span<T>, Span<T>) Inequality(Span<T>, Span<T>) Inequality(Span<T>, Span<T>) Inequality(Span<T>, Span<T>)

Returns a value that indicates whether two Span<T> objects are not equal.

Extension Methods

BinarySearch<T>(Span<T>, IComparable<T>) BinarySearch<T>(Span<T>, IComparable<T>) BinarySearch<T>(Span<T>, IComparable<T>) BinarySearch<T>(Span<T>, IComparable<T>)
BinarySearch<T,TComparer>(Span<T>, T, TComparer) BinarySearch<T,TComparer>(Span<T>, T, TComparer) BinarySearch<T,TComparer>(Span<T>, T, TComparer) BinarySearch<T,TComparer>(Span<T>, T, TComparer)
BinarySearch<T,TComparable>(Span<T>, TComparable) BinarySearch<T,TComparable>(Span<T>, TComparable) BinarySearch<T,TComparable>(Span<T>, TComparable) BinarySearch<T,TComparable>(Span<T>, TComparable)
EndsWith<T>(Span<T>, ReadOnlySpan<T>) EndsWith<T>(Span<T>, ReadOnlySpan<T>) EndsWith<T>(Span<T>, ReadOnlySpan<T>) EndsWith<T>(Span<T>, ReadOnlySpan<T>)
IndexOf<T>(Span<T>, T) IndexOf<T>(Span<T>, T) IndexOf<T>(Span<T>, T) IndexOf<T>(Span<T>, T)
IndexOf<T>(Span<T>, ReadOnlySpan<T>) IndexOf<T>(Span<T>, ReadOnlySpan<T>) IndexOf<T>(Span<T>, ReadOnlySpan<T>) IndexOf<T>(Span<T>, ReadOnlySpan<T>)
IndexOfAny<T>(Span<T>, T, T) IndexOfAny<T>(Span<T>, T, T) IndexOfAny<T>(Span<T>, T, T) IndexOfAny<T>(Span<T>, T, T)
IndexOfAny<T>(Span<T>, T, T, T) IndexOfAny<T>(Span<T>, T, T, T) IndexOfAny<T>(Span<T>, T, T, T) IndexOfAny<T>(Span<T>, T, T, T)
IndexOfAny<T>(Span<T>, ReadOnlySpan<T>) IndexOfAny<T>(Span<T>, ReadOnlySpan<T>) IndexOfAny<T>(Span<T>, ReadOnlySpan<T>) IndexOfAny<T>(Span<T>, ReadOnlySpan<T>)
LastIndexOf<T>(Span<T>, T) LastIndexOf<T>(Span<T>, T) LastIndexOf<T>(Span<T>, T) LastIndexOf<T>(Span<T>, T)
LastIndexOf<T>(Span<T>, ReadOnlySpan<T>) LastIndexOf<T>(Span<T>, ReadOnlySpan<T>) LastIndexOf<T>(Span<T>, ReadOnlySpan<T>) LastIndexOf<T>(Span<T>, ReadOnlySpan<T>)
LastIndexOfAny<T>(Span<T>, T, T) LastIndexOfAny<T>(Span<T>, T, T) LastIndexOfAny<T>(Span<T>, T, T) LastIndexOfAny<T>(Span<T>, T, T)
LastIndexOfAny<T>(Span<T>, T, T, T) LastIndexOfAny<T>(Span<T>, T, T, T) LastIndexOfAny<T>(Span<T>, T, T, T) LastIndexOfAny<T>(Span<T>, T, T, T)
LastIndexOfAny<T>(Span<T>, ReadOnlySpan<T>) LastIndexOfAny<T>(Span<T>, ReadOnlySpan<T>) LastIndexOfAny<T>(Span<T>, ReadOnlySpan<T>) LastIndexOfAny<T>(Span<T>, ReadOnlySpan<T>)
Overlaps<T>(Span<T>, ReadOnlySpan<T>) Overlaps<T>(Span<T>, ReadOnlySpan<T>) Overlaps<T>(Span<T>, ReadOnlySpan<T>) Overlaps<T>(Span<T>, ReadOnlySpan<T>)
Overlaps<T>(Span<T>, ReadOnlySpan<T>, Int32) Overlaps<T>(Span<T>, ReadOnlySpan<T>, Int32) Overlaps<T>(Span<T>, ReadOnlySpan<T>, Int32) Overlaps<T>(Span<T>, ReadOnlySpan<T>, Int32)
Reverse<T>(Span<T>) Reverse<T>(Span<T>) Reverse<T>(Span<T>) Reverse<T>(Span<T>)
SequenceCompareTo<T>(Span<T>, ReadOnlySpan<T>) SequenceCompareTo<T>(Span<T>, ReadOnlySpan<T>) SequenceCompareTo<T>(Span<T>, ReadOnlySpan<T>) SequenceCompareTo<T>(Span<T>, ReadOnlySpan<T>)
SequenceEqual<T>(Span<T>, ReadOnlySpan<T>) SequenceEqual<T>(Span<T>, ReadOnlySpan<T>) SequenceEqual<T>(Span<T>, ReadOnlySpan<T>) SequenceEqual<T>(Span<T>, ReadOnlySpan<T>)
StartsWith<T>(Span<T>, ReadOnlySpan<T>) StartsWith<T>(Span<T>, ReadOnlySpan<T>) StartsWith<T>(Span<T>, ReadOnlySpan<T>) StartsWith<T>(Span<T>, ReadOnlySpan<T>)
AsBytes<T>(Span<T>) AsBytes<T>(Span<T>) AsBytes<T>(Span<T>) AsBytes<T>(Span<T>)
IndexOf(Span<Byte>, Byte) IndexOf(Span<Byte>, Byte) IndexOf(Span<Byte>, Byte) IndexOf(Span<Byte>, Byte)
IndexOf(Span<Byte>, ReadOnlySpan<Byte>) IndexOf(Span<Byte>, ReadOnlySpan<Byte>) IndexOf(Span<Byte>, ReadOnlySpan<Byte>) IndexOf(Span<Byte>, ReadOnlySpan<Byte>)
IndexOf<T>(Span<T>, T) IndexOf<T>(Span<T>, T) IndexOf<T>(Span<T>, T) IndexOf<T>(Span<T>, T)
IndexOf<T>(Span<T>, ReadOnlySpan<T>) IndexOf<T>(Span<T>, ReadOnlySpan<T>) IndexOf<T>(Span<T>, ReadOnlySpan<T>) IndexOf<T>(Span<T>, ReadOnlySpan<T>)
IndexOfAny(Span<Byte>, Byte, Byte) IndexOfAny(Span<Byte>, Byte, Byte) IndexOfAny(Span<Byte>, Byte, Byte) IndexOfAny(Span<Byte>, Byte, Byte)
IndexOfAny(Span<Byte>, Byte, Byte, Byte) IndexOfAny(Span<Byte>, Byte, Byte, Byte) IndexOfAny(Span<Byte>, Byte, Byte, Byte) IndexOfAny(Span<Byte>, Byte, Byte, Byte)
IndexOfAny(Span<Byte>, ReadOnlySpan<Byte>) IndexOfAny(Span<Byte>, ReadOnlySpan<Byte>) IndexOfAny(Span<Byte>, ReadOnlySpan<Byte>) IndexOfAny(Span<Byte>, ReadOnlySpan<Byte>)
NonPortableCast<TFrom,TTo>(Span<TFrom>) NonPortableCast<TFrom,TTo>(Span<TFrom>) NonPortableCast<TFrom,TTo>(Span<TFrom>) NonPortableCast<TFrom,TTo>(Span<TFrom>)
SequenceEqual(Span<Byte>, ReadOnlySpan<Byte>) SequenceEqual(Span<Byte>, ReadOnlySpan<Byte>) SequenceEqual(Span<Byte>, ReadOnlySpan<Byte>) SequenceEqual(Span<Byte>, ReadOnlySpan<Byte>)
SequenceEqual<T>(Span<T>, ReadOnlySpan<T>) SequenceEqual<T>(Span<T>, ReadOnlySpan<T>) SequenceEqual<T>(Span<T>, ReadOnlySpan<T>) SequenceEqual<T>(Span<T>, ReadOnlySpan<T>)
StartsWith(Span<Byte>, ReadOnlySpan<Byte>) StartsWith(Span<Byte>, ReadOnlySpan<Byte>) StartsWith(Span<Byte>, ReadOnlySpan<Byte>) StartsWith(Span<Byte>, ReadOnlySpan<Byte>)
StartsWith<T>(Span<T>, ReadOnlySpan<T>) StartsWith<T>(Span<T>, ReadOnlySpan<T>) StartsWith<T>(Span<T>, ReadOnlySpan<T>) StartsWith<T>(Span<T>, ReadOnlySpan<T>)

Applies to