Constructor ReadOnlyExSpan
ReadOnlyExSpan(T[]?)
Creates a new ReadOnlyExSpan<T> over the entirety of the target array (在整个指定数组中创建新的 ReadOnlyExSpan<T>).
public ReadOnlyExSpan(T[]? array)
Parameters
array
T[]The target array (指定数组).
Remarks
Returns default when array
is null (当 array 为 null 时返回默认值).
ReadOnlyExSpan(T[]?, nint, nint)
Creates a new ReadOnlyExSpan<T> over the portion of the target array beginning at 'start' index and ending at 'end' index (exclusive) (创建一个新的 ReadOnlyExSpan<T>,其中包含从指定索引开始的数组的指定数量的元素).
[FakeCLSCompliant(false)]
public ReadOnlyExSpan(T[]? array, nint start, nint length)
Parameters
array
T[]The target array (指定数组).
start
nintThe zero-based index at which to begin the span (从零开始的跨度索引).
length
nintThe number of items in the span (跨度的项数).
Remarks
Returns default when array
is null (当 array 为 null 时返回默认值).
Exceptions
- ArgumentOutOfRangeException
Thrown when the specified
start
or end index is not in the range (<0 or >Length).
ReadOnlyExSpan(void*, nint)
Creates a new ReadOnlyExSpan<T> over the target unmanaged buffer (在目标非托管缓冲区上创建新 ReadOnlyExSpan<T>).
[CLSCompliant(false)]
public ReadOnlyExSpan(void* pointer, nint length)
Parameters
pointer
void*An unmanaged pointer to memory (指向内存的非托管指针).
length
nintThe number of
T
elements the memory contains (内存中包含的T
元素数量).
Exceptions
- ArgumentException
Thrown when
T
is reference type or contains pointers and hence cannot be stored in unmanaged memory.
ReadOnlyExSpan(ref readonly T)
Creates a new ReadOnlyExSpan<T> of length 1 around the specified reference (在指定的引用周围创建长度为 1 的新 ReadOnlyExSpan<T>).
public ReadOnlyExSpan(ref readonly T reference)
Parameters
reference
TA reference to data (数据的引用).