I was wondering about the order that a foreach loop in C# loops through a System.Collections.Generic.List object.
I found another question abou
On Microsoft Reference Source page for List Enumerator it is explicitly stated that the iteration is done from 0 to Length-1:
internal Enumerator(List list) {
this.list = list;
index = 0;
version = list._version;
current = default(T);
}
public bool MoveNext() {
List localList = list;
if (version == localList._version && ((uint)index < (uint)localList._size))
{
current = localList._items[index];
index++;
return true;
}
return MoveNextRare();
}
Hope it's still relevant for somebody