METHOD

List<T>.GetRange

Creates a shallow sublist with count elements beginning at start. The second argument is a length, not an exclusive end index. Reference-valued elements remain shared.

Formal Syntax & Structure

csharp syntaxcsharp
items.GetRange(start, count)

Working Example

Example Snippetcsharp
using System;using System.Collections.Generic;var items = new List<int> { 1, 2, 3, 4 };Console.WriteLine(string.Join(",", items.GetRange(1, 2))); // 2,3
C# & .NET Reference