hawbsl
hawbsl

Reputation: 16003

LINQ syntax to take all rows except the first one?

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

Upvotes: 8

Views: 4142

Answers (2)

DaveShaw
DaveShaw

Reputation: 52788

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

var allButFirst = rows.Skip(1);

Upvotes: 4

Randolpho
Randolpho

Reputation: 56381

var allButTheFirst = collection.Skip(1);

More info:

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

Upvotes: 20

Related Questions