Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LINQ syntax to take all rows except the first one?

Tags:

.net

linq

What's the LINQ syntax to take all rows except the first one? Does LINQ offer a nice concise way to do it?

like image 692
hawbsl Avatar asked Jan 19 '12 15:01

hawbsl


2 Answers

var allButTheFirst = collection.Skip(1);

More info:

http://msdn.microsoft.com/en-us/library/bb358985.aspx

like image 171
Randolpho Avatar answered Sep 30 '22 03:09

Randolpho


You can use the Skip(TSource) extension method on any IEnumerable.

var allButFirst = rows.Skip(1);
like image 29
DaveShaw Avatar answered Sep 30 '22 03:09

DaveShaw