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

定义

重载

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

在整个指定数组上创建新的 Span<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)

从指定的内存地址开始,从指定 T 元素数创建新的 Span<T> 对象。Creates a new Span<T> object from a specified number of T elements starting at a specified memory address.

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

从指定索引开始,创建包含数组的指定元素数的新 Span<T> 对象。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[])

在整个指定数组上创建新的 Span<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())

参数

array
T[]

用来从中创建 Span<T> 对象的数组。The array from which to create the Span<T> object.

异常

T 为引用类型,并且 array 不是 T 类型的数组。T is a reference type, and array is not an array of type T.

注解

如果arraynull ,则此null构造函数返回。 Span<T>If array is null, this constructor returns a null Span<T>.

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

重要

此 API 不符合 CLS。

从指定的内存地址开始,从指定 T 元素数创建新的 Span<T> 对象。Creates a new Span<T> object from a specified number of T elements 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>

参数

pointer
Void*

指向内存中指定 T 元素数的起始地址的指针。A pointer to the starting address of a specified number of T elements in memory.

length
Int32 Int32 Int32 Int32

要包含在 Span<T> 中的 T 元素数。The number of T elements to be included in the Span<T>.

异常

T 是引用类型或包含指针,因此不能存储在非管理的内存中。T is a reference type or contains pointers and therefore cannot be stored in unmanaged memory.

注解

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, Int32) Span<T>(T[], Int32, Int32) Span<T>(T[], Int32, Int32) Span<T>(T[], Int32, Int32)

从指定索引开始,创建包含数组的指定元素数的新 Span<T> 对象。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)

参数

array
T[]

源数组。The source array.

start
Int32 Int32 Int32 Int32

要包括在新的 Span<T> 内的第一个元素的索引。The index of the first element to include in the new Span<T>.

length
Int32 Int32 Int32 Int32

要包括在新的 Span<T> 中的元素数。The number of elements to include in the new Span<T>.

异常

arraynull,但 startlength 不为零。array is null, but start or length is non-zero.

-or-

start 在数组的界限外。start is outside the bounds of the array.

- 或 --or-

startlength 超过数组中的元素数。start and length exceeds the number of elements in the array.

T 为引用类型,并且 array 不是 T 类型的数组。T is a reference type, and array is not an array of type T.

注解

#

当为时default arraynull此方法返回。This method returns default when array is null.

适用于