LINQ Take & Skip

By Riley K

In some cases we want to Skip few items and take the remaining like in a List LINQ offers a greate way using Take() and Skip() Methods

var list = new List<int>();

From the above list I want to skip the first 2 items and take the remaining.

var result = from res in list.Skip<int>(2).Take<int>(5)
                           select r

 foreach (int r in result)
     Console.WriteLine("{0}", r.ToString());

LINQ Take & Skip  (2932 Views)