|
|
Browse by Tags
All Tags » C# » .NET » Sequence number
-
A few weeks ago I was writing a Linq query where I needed each items sequence number (or index) as a part of the filter expression in a Where operation. To simplify the actual problem let's say I needed to filter out only the odd items. One (wrong) way to do this would be:
int i = 0;
var filtered = input.Where(x => i++ % 2 == 1);
This ...
|
|
|