I have custom class that implement IEnumerable<int[]> interface and save current Enumerator. When added new element I need set enumerator to last element.
Sample code for set enumerator to end:
IEnumerable<int> seq = ...
seq.Reset();
for (int i = 0; i < seq.Count; i++)
{
seq.MoveNext();
}
How do this faster?
(Can I go to the end can’t not scroll all sequence elements?)
if faster means less code (another alternative is),
EDIT
you want seq.Last()
It is an extension method and has code similar to above.
EDIT2
your code is similar to
Using IEnumerator only it is not possible to set seq.Current to Last in one iteration as you never know where to stop.