IOrderedDictionary elements can be accessed either with the key or with the index.
Each element is a key/value pair stored in a DictionaryEntry structure.
Each pair must have a unique key that is not nullNothingnullptra null reference (Nothing in Visual Basic), but the value can be nullNothingnullptra null reference (Nothing in Visual Basic) and does not have to be unique. The IOrderedDictionary interface allows the contained keys and values to be enumerated, but it does not imply any particular sort order.
vb#c#
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 IDictionary 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. For example:
|
foreach (DictionaryEntry de in myOrderedDictionary) {...}
|
|
For Each de As DictionaryEntry In myOrderedDictionary
...
Next de
|
vb#c#
The foreach statement is a wrapper around the enumerator, which allows only reading from, not writing to, the collection.
Notes to Implementers:
The implementing class must have a means to compare keys.