Use Skip Operators in Linq.

We want to use Skip Operators in Linq query. How to use this please help me. 
Last updated:3/21/2016 11:19:13 PM

1 Answers

Aditya Patel
Aditya Patel

Skips elements up to a specified position starting from the first element in a sequence.

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace Prototype

{

class Example

{

static void Main()

{

IList<employee> List = new List<employee>() {

new employee() { id = 1, empname = 'Rohit', age = 18 } ,

new employee() { id = 2, empname = 'Manoj', age = 15 } ,

new employee() { id = 3, empname = 'Anupam', age = 25 } ,

new employee() { id = 4, empname = 'Shiv' , age = 20 } ,

new employee() { id = 5, empname = 'Sohan' , age = 19 },

new employee() { id = 6, empname = 'Mohan' , age = 18 }

};

var skipResult = List.Skip(3);

foreach (employee emp in skipResult)

Console.WriteLine('Id:' + emp.id + ', Name:' + emp.empname + ', Age:' + emp.age);

Console.ReadLine();

}

}

class employee

{

public int id { get; set; }

public string empname { get; set; }

public int age { get; set; }

}

}

Answer