IDictionary Interface
Represents a nongeneric collection of key/value pairs.
Assembly: mscorlib (in mscorlib.dll)
The IDictionary interface is the base interface for nongeneric collections of key/value pairs. For the generic version of this interface, see System.Collections.Generic.IDictionary(TKey, TValue).
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 a null reference (Nothing in Visual Basic). The value can be a null reference (Nothing in Visual Basic) 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.
[Visual Basic, 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 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:
[Visual Basic, C#]
The foreach statement is a wrapper around the enumerator, which allows only reading from but not writing to the collection.
Notes to Implementers:The implementing class must have a means to compare keys.
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC, Xbox 360, Zune
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.