title: In what order does a C# for each loop iterate over a List<T>?
body: <p>I was wondering about the order that a foreach loop in C# loops through a <code>System.Collections.Generic.List&lt;T&gt;</code> object.</p>
  
  <p>I found <a href="https://stackoverflow.com/questions/678162/sort-order-when-using-foreach-on-an-array-list-etc">another question</a> about the same topic, but I do not feel that it answers my question to my satisfaction.</p>
  
  <p>Someone states that no order is defined. But as someone else states, the order it traverses an array is fixed (from 0 to Length-1). <a href="http://msdn.microsoft.com/en-us/library/aa664754(VS.71).aspx" rel="noreferrer">8.8.4 The foreach statement</a></p>
  
  <p>It was also said that the same holds for any standard classes with an order (e.g. <code>List&lt;T&gt;</code>).  I can not find any documentation to back that up. So for all I know it might work like that now, but maybe in the next .NET version it will be different (even though it might be unlikely). </p>
  
  <p>I have also looked at the <a href="http://msdn.microsoft.com/en-us/library/x854yt9s.aspx" rel="noreferrer"><code>List(t).Enumerator</code></a> documentation without luck.</p>
  
  <p><a href="https://stackoverflow.com/questions/1376934/java-for-each-loop-sort-order">Another related question</a> states that for Java, it is specifically mentioned in the documentation: </p>
  
  <blockquote>
    <p><code>List.iterator()</code>returns an iterator over the elements in this list
    in proper sequence."</p>
  </blockquote>
  
  <p>I am looking for something like that in the C# documentation.</p>
  
  <p>Thanks in advance.</p>
  
  <p>Edit: Thank you for all you for all your answers (amazing how fast I got so many replies). What I understand from all the answers is that <code>List&lt;T&gt;</code> does always iterate in the order of its indexing. But I still would like to see a clear peace of documentation stating this, similar to the <a href="http://java.sun.com/javase/6/docs/api/java/util/List.html#iterator()" rel="noreferrer">Java documentation on <code>List</code></a>.</p>