I just saw this behaviour and I\'m a bit surprised by it...
If I add 3 or 4 elements to a Dictionary, and then do a \"For Each\" to get all the keys, they appear in
The question and many of the answers seem to misunderstand the purpose of a hashtable or dictionary. These data structures have no specified behaviors with respect to the enumeration of the values (or in fact the keys) of the items contained in the data structure.
The purpose of a dictionary or hashtable is to be able to efficiently lookup a specific value given a known key. The internal implementation of any dictionary or hashtable should provide for this efficiency in lookups but need not provide any specific behavior with respect to enumerations or "for each" type iterations on the values or keys.
In short, the internal data structure can store and enumerate these values in any manner that it wishes, including the order that they were inserted.