GetEnumerator
and
GetAsyncEnumerator
return a
new instance
of an enumerator. As a result...
var e1 = sequence.GetEnumerator();
var e2 = sequence.GetEnumerator();
Console.WriteLine(e1 == e2); // false!!!
Corollary1: if we call
e1.MoveNext()
, the
Current
value changes in
e1
but not in
e2
.
Corollary2: The following will produce surprising results.
while(sequence.GetEnumerator().MoveNext())
{
Console.WriteLine(sequence.GetEnumerator().Current); // always empty
Corollary3: If I ruled the world, we might rename it to
CreateNewEnumerator
.