Table of Contents

Constructor ExSpan

Namespace
Zyl.ExSpans
Assembly
ExSpans.Core.dll

ExSpan(T[]?)

Creates a new ExSpan<T> over the entirety of the target array (在整个指定数组中创建新的 ExSpan<T>).

public ExSpan(T[]? array)

Parameters

array T[]

The target array (指定数组).

Remarks

Returns default when array is null (当 array 为 null 时返回默认值).

Exceptions

ArrayTypeMismatchException

Thrown when array is covariant and array's type is not exactly T[].

ExSpan(T[]?, nint, nint)

Creates a new ExSpan<T> over the portion of the target array beginning at 'start' index and ending at 'end' index (exclusive) (创建一个新的 ExSpan<T>,其中包含从指定索引开始的数组的指定数量的元素).

[FakeCLSCompliant(false)]
public ExSpan(T[]? array, nint start, nint length)

Parameters

array T[]

The target array (指定数组).

start nint

The zero-based index at which to begin the span (从零开始的跨度索引).

length nint

The number of items in the span (跨度的项数).

Remarks

Returns default when array is null (当 array 为 null 时返回默认值).

Exceptions

ArrayTypeMismatchException

Thrown when array is covariant and array's type is not exactly T[].

ArgumentOutOfRangeException

Thrown when the specified start or end index is not in the range (<0 or >Length).

ExSpan(void*, nint)

Creates a new ExSpan<T> over the target unmanaged buffer (在目标非托管缓冲区上创建新 ExSpan<T>).

[CLSCompliant(false)]
public ExSpan(void* pointer, nint length)

Parameters

pointer void*

An unmanaged pointer to memory (指向内存的非托管指针).

length nint

The 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.

ArgumentOutOfRangeException

Thrown when the specified length is negative.

ExSpan(ref T)

Creates a new ExSpan<T> of length 1 around the specified reference (在指定的引用周围创建长度为 1 的新 ExSpan<T>).

public ExSpan(ref T reference)

Parameters

reference T

A reference to data (数据的引用).