IDictionary Interface

Represents a nongeneric collection of key/value pairs.

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

No code example is currently available or this language may not be supported.

The IDictionary type exposes the following members.

  NameDescription
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360CountGets the number of elements contained in the ICollection. (Inherited from ICollection.)
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360IsFixedSizeGets a value indicating whether the IDictionary object has a fixed size.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360IsReadOnlyGets a value indicating whether the IDictionary object is read-only.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360IsSynchronizedGets a value indicating whether access to the ICollection is synchronized (thread safe). (Inherited from ICollection.)
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360ItemGets or sets the element with the specified key.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360KeysGets an ICollection object containing the keys of the IDictionary object.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360SyncRootGets an object that can be used to synchronize access to the ICollection. (Inherited from ICollection.)
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360ValuesGets an ICollection object containing the values in the IDictionary object.
Top

  NameDescription
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360AddAdds an element with the provided key and value to the IDictionary object.
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360ClearRemoves all elements from the IDictionary object.
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360ContainsDetermines whether the IDictionary object contains an element with the specified key.
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360CopyToCopies the elements of the ICollection to an Array, starting at a particular Array index. (Inherited from ICollection.)
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360GetEnumerator()Returns an IDictionaryEnumerator object for the IDictionary object.
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360GetEnumerator()Returns an enumerator that iterates through a collection. (Inherited from IEnumerable.)
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360RemoveRemoves the element with the specified key from the IDictionary object.
Top

  NameDescription
Public Extension MethodSupported by Silverlight for Windows PhoneAsQueryableConverts an IEnumerable to an IQueryable. (Defined by Queryable.)
Public Extension MethodSupported by Silverlight for Windows PhoneSupported by Xbox 360Cast<TResult>Converts the elements of an IEnumerable to the specified type. (Defined by Enumerable.)
Public Extension MethodSupported by Silverlight for Windows PhoneSupported by Xbox 360OfType<TResult>Filters the elements of an IEnumerable based on a specified type. (Defined by Enumerable.)
Top

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 nullptr. The value can be nullptr 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:

No code example is currently available or this language may not be supported.

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.

The following code example demonstrates how to define a simple dictionary class that implements the IDictionary interface.

No code example is currently available or this language may not be supported.

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show: