I have a collection.
I want to project from it only first N that are not deleted.
However I want to count how many elements (deleted and non-deleted)
I traversed till got to the Nth non-deleted element.
How can I do it?
i thought to use side effect:
int i;
collectiom.Skip(Convert.ToInt32(startIndex))
.TakeWhile( x=>
{
++i != 0;
return (!x.IsDeleted)
})
.Take(N);
But the compiler refuses.
And now I see it’s not answering my need anyway
TIA
How about this:
The result is a sequence of
Nanonymous objects wherex.Itemis the original object, andx.Indexis its index in the original collection. If you want to start counting the original collection fromstartIndexjust swap theSelectandSkipcalls.You can then get the number you want like so: