Skip to content

Instantly share code, notes, and snippets.

@SergeyTeplyakov
Created April 27, 2014 09:33
Show Gist options
  • Save SergeyTeplyakov/11341486 to your computer and use it in GitHub Desktop.
Save SergeyTeplyakov/11341486 to your computer and use it in GitHub Desktop.
var list = new List<int>{42};
var lIter = list.GetEnumerator();
lIter.MoveNext();
list.Add(12);
Console.WriteLine(lIter.Current); // 1
Console.WriteLine(lIter.MoveNext()); // 2
// Тоже самое но с LinkedList
var linked = new LinkedList<int>();
var linkedIter = linked.GetEnumerator();
linkedIter.MoveNext();
// Инициализатор коллекций не работает для LinkedList
linked.AddLast(12);
Console.WriteLine(linkedIter.Current); // 3
Console.WriteLine(linkedIter.MoveNext()) // 4
@Spaider
Copy link

Spaider commented Apr 27, 2014

Точка с запятой пропущена в 17 строчке

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment