SIGN UP MEMBER LOGIN:    
Resource

Usage of LINQ Take and Skip

Hemant Kumar Resources Oct 13, 2011
This resource is used to give the basic description about the LINQ "Take" and "Skip".

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


var list = new List<int>();
            list.Add(2);
            list.Add(3);
            list.Add(5);
            list.Add(7);
            list.Add(57);
            list.Add(47);
            list.Add(17);
            list.Add(27);

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
es;

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

share this resource :
post comment
 
Nevron Gauge for SharePoint
Become a Sponsor
PREMIUM SPONSORS
  • Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
    Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
Sponsored by
Team Foundation Server Hosting
Become a Sponsor