ReadOnlySpan<T> ReadOnlySpan<T> ReadOnlySpan<T> ReadOnlySpan<T> Constructors

定义

重载

ReadOnlySpan<T>(T[]) ReadOnlySpan<T>(T[]) ReadOnlySpan<T>(T[]) ReadOnlySpan<T>(T[])

在整个指定数组上创建新的 ReadOnlySpan<T>Creates a new ReadOnlySpan<T> over the entirety of a specified array.

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

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

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

从指定索引开始,创建包含数组的指定元素数的新 ReadOnlySpan<T>Creates a new ReadOnlySpan<T> that includes a specified number of elements of an array starting at a specified index.

ReadOnlySpan<T>(T[]) ReadOnlySpan<T>(T[]) ReadOnlySpan<T>(T[]) ReadOnlySpan<T>(T[])

在整个指定数组上创建新的 ReadOnlySpan<T>Creates a new ReadOnlySpan<T> over the entirety of a specified array.

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

参数

array
T[]

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

注解

如果数组为空, 则此构造函数返回 null ReadOnlySpan<T>If the array is null, this constructor returns a null ReadOnlySpan<T>.

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

重要

此 API 不符合 CLS。

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

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

参数

pointer
Void*

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

length
Int32 Int32 Int32 Int32

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

异常

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

注解

此构造函数应谨慎使用, 因为它在内存块中T创建任意类型的。This constructor should be used with care, since it creates arbitrarily typed Ts from a block of memory.

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

从指定索引开始,创建包含数组的指定元素数的新 ReadOnlySpan<T>Creates a new ReadOnlySpan<T> that includes a specified number of elements of an array starting at a specified index.

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

参数

array
T[]

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

start
Int32 Int32 Int32 Int32

要包含的第一个元素的索引。The index of the first element to include.

length
Int32 Int32 Int32 Int32

要包含的元素的数目。The number of elements to include.

异常

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.

注解

#

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

适用于