Span<T> Span<T> Span<T> Span<T> Constructors

Definition

Overloads

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)

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.

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.

public:
 Span(cli::array <T> ^ array);
public Span (T[] array);
new Span<'T> : 'T[] -> Span<'T>
Public Sub New (array As T())
Parameters
array
T[]

The array from which to create the Span<T> object.

Exceptions
System.TypeMismatchException System.TypeMismatchException System.TypeMismatchException System.TypeMismatchException

T is a reference type, and array is not an array of type T.

Remarks

If array is null, this constructor returns a null Span<T>.

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

Important

This API is not CLS-compliant.

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

public:
 Span(void* pointer, int length);
[System.CLSCompliant(false)]
public Span (void* pointer, int length);
new Span<'T> : nativeptr<unit> * int -> Span<'T>
Parameters
pointer
Void*

A pointer to the starting address of a specified number of bytes in memory.

length
Int32 Int32 Int32 Int32

The number of bytes to be included in the Span<T>.

Exceptions

T is a reference type or contains pointers and therefore cannot be stored in unmanaged memory.

Remarks

This constructor should be used with care, since it creates arbitrarily typed Ts from a void*-typed block of memory, and length is not checked. However, if the constructor succeeds in creating a new Span<T> object, all subsequent uses are correct.

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.

public:
 Span(cli::array <T> ^ array, int start);
public Span (T[] array, int start);
new Span<'T> : 'T[] * int -> Span<'T>
Public Sub New (array As T(), start As Integer)
Parameters
array
T[]

The source array.

start
Int32 Int32 Int32 Int32

The index of the first element in the array to include in the Span<T> object.

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.

public:
 Span(cli::array <T> ^ array, int start, int length);
public Span (T[] array, int start, int length);
new Span<'T> : 'T[] * int * int -> Span<'T>
Public Sub New (array As T(), start As Integer, length As Integer)
Parameters
array
T[]

The source array.

start
Int32 Int32 Int32 Int32

The index of the first element to include in the new Span<T>.

length
Int32 Int32 Int32 Int32

The number of elements to include in the new Span<T>.

Exceptions

array is null, but start or length is non-zero.

--or--

start is outside the bounds of the array.

--or--

start and length exceeds the number of elements in the array.

System.TypeMismatchException System.TypeMismatchException System.TypeMismatchException System.TypeMismatchException

T is a reference type, and array is not an array of type T.

Applies to