System.Collections.Generic.List<T>.GetRange Method
Creates a shallow copy of a range of elements in the current List.

Syntax

public List<T> GetRange (int index, int count)

Parameters

index
The zero-based index at which the range starts.
count
The number of elements in the range.

Returns

A shallow copy of the given range of elements in the list.

Exceptions

TypeReason
ArgumentException index + count is greater than stem.Collections.Generic.List<T>.Count.
ArgumentOutOfRangeException

index is less than 0.

-or-

count is less than 0.

Remarks

A shallow copy of a collection, or a subset of that collection, copies only the elements of the collection, whether they are reference types or value types, but it does not copy the objects that the references refer to. The references in the new collection point to the same objects as do the references in the original collection. (In contrast, a deep copy of a collection copies the elements and everything directly or indirectly referenced by those elements.)

Requirements

Namespace: System.Collections.Generic
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0
Since: .NET 2.0