Each element is a key/value pair stored in a DictionaryEntry object. A key cannot be a null reference (Nothing in Visual Basic), but a value can be.
The elements of an OrderedDictionary are not sorted in any way. OrderedDictionary collections allow access by both index as well as key.
The foreach statement of the C# language (For Each in Visual Basic) requires the type of each element in the collection. Since each element of the OrderedDictionary collection is a key/value pair, the element type is not the type of the key or the type of the value. Instead, the element type is DictionaryEntry. The following code shows C# and Visual Basic syntax.
foreach (DictionaryEntry de in myListDictionary) {...}
For Each de As DictionaryEntry In myListDictionary
...
Next de
The foreach statement is a wrapper around the enumerator, which only allows reading from, not writing to, the collection.