Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

IDictionary Interface

Represents a collection of key-and-value pairs.

For a list of all members of this type, see IDictionary Members.

[Visual Basic]
Public Interface IDictionary
   Inherits ICollection, IEnumerable
[C#]
public interface IDictionary : ICollection, IEnumerable
[C++]
public __gc __interface IDictionary : public ICollection,
   IEnumerable
[JScript]
public interface IDictionary implements ICollection, IEnumerable

Classes that Implement IDictionary

Class Description
BaseChannelObjectWithProperties Provides a base implementation of a channel object that wants to provide a dictionary interface to its properties.
DictionaryBase Provides the abstract (MustInherit in Visual Basic) base class for a strongly typed collection of key-and-value pairs.
Hashtable Represents a collection of key-and-value pairs that are organized based on the hash code of the key.
HybridDictionary Implements IDictionary by using a ListDictionary while the collection is small, and then switching to a Hashtable when the collection gets large.
ListDictionary Implements IDictionary using a singly linked list. Recommended for collections that typically contain 10 items or less.
PropertyCollection Contains the properties of a DirectoryEntry.
PropertyDescriptorCollection Represents a collection of PropertyDescriptor objects.
SortedList Represents a collection of key-and-value pairs that are sorted by the keys and are accessible by key and by index.
StateBag Manages the view state of ASP.NET server controls, including pages. This class cannot be inherited.

Remarks

The IDictionary class is the base interface for collections of key-and-value pairs.

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

Each association must have a unique key that is not a null reference (Nothing in Visual Basic), but the value of an association can be any object reference, including a null reference (Nothing). 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 cannot be modified. A fixed-size IDictionary does not allow the addition or removal of elements, but it allows the modification of existing elements. A variable-size IDictionary 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 is a key-and-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:

[C#] 
foreach (DictionaryEntry myDE in myHashtable) {...}
[Visual Basic] 
Dim myDE As DictionaryEntry
For Each myDE In myHashtable
   ...
Next myDE

[Visual Basic, C#] The foreach statement is a wrapper around the enumerator, which only allows reading from, not writing to, the collection.

Requirements

Namespace: System.Collections

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

Assembly: Mscorlib (in Mscorlib.dll)

See Also

IDictionary Members | System.Collections Namespace | Hashtable

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft