Strange behavior of Enumerator.MoveNext()
List<T>.GetEnumerator() returns a mutable value type (List<T>.Enumerator). You’re storing that value in the anonymous type. Now, let’s have a look at what this does: while (x.TempList.MoveNext()) { // Ignore this } That’s equivalent to: while (true) { var tmp = x.TempList; var result = tmp.MoveNext(); if (!result) { break; } // Original loop body } … Read more