System.Collections.IDictionary

Represents a nongeneric collection of key/value pairs.

See Also: IDictionary Members

Syntax

[System.Runtime.InteropServices.ComVisible(true)]
public interface IDictionary : ICollection

Remarks

The IDictionary interface is the base interface for nongeneric collections of key/value pairs. For the generic version of this interface, see IDictionary`2.

Each element is a key/value pair stored in a DictionaryEntry object.

Each pair must have a unique key. Implementations can vary in whether they allow the key to be null. The value can be null and does not have to be unique. The IDictionary interface allows the contained keys and values to be enumerated, but it does not imply any particular sort order.

IDictionary implementations fall into three categories: read-only, fixed-size, variable-size. A read-only IDictionary object cannot be modified. A fixed-size IDictionary object does not allow the addition or removal of elements, but does allow the modification of existing elements. A variable-size IDictionary object allows the addition, removal, and modification of elements.

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 object 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:

code reference: Dictionary#14

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

Requirements

Namespace: System.Collections
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0