See Also: IDictionary<TKey,TValue> Members
- TKey
- Documentation for this section has not yet been entered.
- TValue
- Documentation for this section has not yet been entered.
The IDictionary`2 interface is the base interface for generic collections of key/value pairs.
Each element is a key/value pair stored in a KeyValuePair`2 object.
Each pair must have a unique key. Implementations can vary in whether they allow key to be null. The value can be null and does not have to be unique. The IDictionary`2 interface allows the contained keys and values to be enumerated, but it does not imply any particular sort order.
The foreach statement of the C# language (For Each in Visual Basic, for each in C++) requires the type of each element in the collection. Since each element of the IDictionary`2 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`2. For example:
code reference: Generic.IDictionary#11
The foreach statement is a wrapper around the enumerator, which only allows reading from, not writing to, the collection.
Because keys can be inherited and their behavior changed, their absolute uniqueness cannot be guaranteed by comparisons using the Type.Equals(object) method.