I'd have to disagree with all the answers so far.
First, the C# 3.0 standard guarantees the order of foreach on an array:
The order in which foreach traverses
the elements of an array, is as
follows: For single-dimensional arrays
elements are traversed in increasing
index order, starting with index 0 and
ending with index Length – 1. For
multi-dimensional arrays, elements are
traversed such that the indices of the
rightmost dimension are increased
first, then the next left dimension,
and so on to the left.
-- C# Language Specification Version 3.0, page 240.
Second, on objects, foreach (C#) and For Each (VB.NET) work by using the MoveNext, Reset, and Current members on an object (source). These are typically part of the IEnumerator interface.
In collections that have an order (read: things that implement IList or IList(T)), this means that the elements will be returned in the order that the backing store stores them.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…