The Dictionary<(Of <(TKey, TValue>)>)..::.Enumerator..::.Current property returns an instance of this type.
The foreach statement of the C# language (for each in C++, For Each in Visual Basic) requires the type of the elements in the collection. Since each element of a collection based on IDictionary<(Of <(TKey, TValue>)>) 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 KeyValuePair<(Of <(TKey, TValue>)>). For example:
|
foreach (KeyValuePair<int, string> kvp in myDictionary) {...}
|
|
for each (KeyValuePair<int, String^> kvp in myDictionary) {...}
|
|
For Each kvp As KeyValuePair(Of Integer, String) In myDictionary
...
Next kvp
|
The foreach statement is a wrapper around the enumerator, which allows only reading from, not writing to, the collection.