ArraySegment<T>.Slice 方法

定义

重载

Slice(Int32)

从指定索引处开始,形成当前数组段的一个切片。Forms a slice out of the current array segment starting at the specified index.

Slice(Int32, Int32)

从指定索引处开始,形成当前数组段的一个指定长度的切片。Forms a slice of the specified length out of the current array segment starting at the specified index.

Slice(Int32)

从指定索引处开始,形成当前数组段的一个切片。Forms a slice out of the current array segment starting at the specified index.

public:
 ArraySegment<T> Slice(int index);
public ArraySegment<T> Slice (int index);
member this.Slice : int -> ArraySegment<'T>
Public Function Slice (index As Integer) As ArraySegment(Of T)

参数

index
Int32

开始切片处的索引。The index at which to begin the slice.

返回

一个数组段,其中包含当前数组段从 index 到数组段末尾的所有元素。An array segment that consists of all elements of the current array segment from index to the end of the array segment.

异常

此实例的基础数组为 nullThe underlying array of this instance is null.

index 大于此实例的基础数组的长度。index is greater than the length of the underlying array of this instance.

Slice(Int32, Int32)

从指定索引处开始,形成当前数组段的一个指定长度的切片。Forms a slice of the specified length out of the current array segment starting at the specified index.

public:
 ArraySegment<T> Slice(int index, int count);
public ArraySegment<T> Slice (int index, int count);
member this.Slice : int * int -> ArraySegment<'T>
Public Function Slice (index As Integer, count As Integer) As ArraySegment(Of T)

参数

index
Int32

开始切片处的索引。The index at which to begin the slice.

count
Int32

切片的所需长度。The desired length of the slice.

返回

index 开始的 count 元素组成的数组段。An array segment of count elements starting at index.

异常

此实例的基础数组为 nullThe underlying array of this instance is null.

index 大于此实例的基础数组的长度。index is greater than the length of the underlying array of this instance.

-or-

count 大于此实例的基础数组的长度 - indexcount is greater than the length of the underlying array of this instance - index.

适用于