List<T>.Slice(Int32, Int32) Method

Definition

Creates a shallow copy of a range of elements in the source List<T>.

C#
public System.Collections.Generic.List<T> Slice(int start, int length);

Parameters

start
Int32

The zero-based List<T> index at which the range starts.

length
Int32

The length of the range.

Returns

A shallow copy of a range of elements in the source List<T>.

Exceptions

start is less than 0.

-or-

length is less than 0.

start and length do not denote a valid range of elements in the List<T>.

Applies to

Proizvod Verzije
.NET 8, 9, 10