IDictionary Interface

 

Represents a nongeneric collection of key/value pairs.

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

[<ComVisibleAttribute(true)>]
type IDictionary = 
    interface
        interface ICollection
        interface IEnumerable
    end

NameDescription
System_CAPS_pubpropertyCount

Gets the number of elements contained in the ICollection.(Inherited from ICollection.)

System_CAPS_pubpropertyIsFixedSize

Gets a value indicating whether the IDictionary object has a fixed size.

System_CAPS_pubpropertyIsReadOnly

Gets a value indicating whether the IDictionary object is read-only.

System_CAPS_pubpropertyIsSynchronized

Gets a value indicating whether access to the ICollection is synchronized (thread safe).(Inherited from ICollection.)

System_CAPS_pubpropertyItem(Object)

Gets or sets the element with the specified key.

System_CAPS_pubpropertyKeys

Gets an ICollection object containing the keys of the IDictionary object.

System_CAPS_pubpropertySyncRoot

Gets an object that can be used to synchronize access to the ICollection.(Inherited from ICollection.)

System_CAPS_pubpropertyValues

Gets an ICollection object containing the values in the IDictionary object.

NameDescription
System_CAPS_pubmethodAdd(Object, Object)

Adds an element with the provided key and value to the IDictionary object.

System_CAPS_pubmethodClear()

Removes all elements from the IDictionary object.

System_CAPS_pubmethodContains(Object)

Determines whether the IDictionary object contains an element with the specified key.

System_CAPS_pubmethodCopyTo(Array, Int32)

Copies the elements of the ICollection to an Array, starting at a particular Array index.(Inherited from ICollection.)

System_CAPS_pubmethodGetEnumerator()

Returns an IDictionaryEnumerator object for the IDictionary object.

System_CAPS_pubmethodRemove(Object)

Removes the element with the specified key from the IDictionary object.

NameDescription
System_CAPS_pubmethodAsParallel()

Overloaded. Enables parallelization of a query.(Defined by ParallelEnumerable.)

System_CAPS_pubmethodAsQueryable()

Overloaded. Converts an IEnumerable to an IQueryable.(Defined by Queryable.)

System_CAPS_pubmethodCast<'TResult>()

Casts the elements of an IEnumerable to the specified type.(Defined by Enumerable.)

System_CAPS_pubmethodOfType<'TResult>()

Filters the elements of an IEnumerable based on a specified type.(Defined by Enumerable.)

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 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) returns an object of the type of the elements 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.

Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
Show: