Represents a generic read-only collection of key/value pairs.

See Also: IReadOnlyDictionary<TKey,TValue> Members


public interface IReadOnlyDictionary<TKey, TValue> : IEnumerable<KeyValuePair<TKey, TValue>>, IReadOnlyCollection<KeyValuePair<TKey, TValue>>

Type Parameters

Documentation for this section has not yet been entered.
Documentation for this section has not yet been entered.


Each element is a key/value pair that is stored in a KeyValuePair`2 object.

Each pair must have a unique key. Implementations can vary in whether they allow you to specify a key that is 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. Because each element of the IReadOnlyDictionary`2 interface 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, as the following example illustrates.

code reference: Generic.IDictionary#11

The foreach statement is a wrapper around the enumerator; it allows only reading from the collection, not writing to the collection.


Namespace: System.Collections.Generic
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: