Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

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

The IDictionary type exposes the following members.

  NameDescription
Public propertySupported by the XNA FrameworkCountGets the number of elements contained in the ICollection. (Inherited from ICollection.)
Public propertySupported by the XNA FrameworkIsFixedSizeGets a value indicating whether the IDictionary object has a fixed size.
Public propertySupported by the XNA FrameworkIsReadOnlyGets a value indicating whether the IDictionary object is read-only.
Public propertySupported by the XNA FrameworkIsSynchronizedGets a value indicating whether access to the ICollection is synchronized (thread safe). (Inherited from ICollection.)
Public propertySupported by the XNA FrameworkItemGets or sets the element with the specified key.
Public propertySupported by the XNA FrameworkKeysGets an ICollection object containing the keys of the IDictionary object.
Public propertySupported by the XNA FrameworkSyncRootGets an object that can be used to synchronize access to the ICollection. (Inherited from ICollection.)
Public propertySupported by the XNA FrameworkValuesGets an ICollection object containing the values in the IDictionary object.
Top

  NameDescription
Public methodSupported by the XNA FrameworkAddAdds an element with the provided key and value to the IDictionary object.
Public methodSupported by the XNA FrameworkClearRemoves all elements from the IDictionary object.
Public methodSupported by the XNA FrameworkContainsDetermines whether the IDictionary object contains an element with the specified key.
Public methodSupported by the XNA FrameworkCopyToCopies the elements of the ICollection to an Array, starting at a particular Array index. (Inherited from ICollection.)
Public methodSupported by the XNA FrameworkGetEnumeratorReturns an IDictionaryEnumerator object for the IDictionary object.
Public methodSupported by the XNA FrameworkRemoveRemoves the element with the specified key from the IDictionary object.
Top

  NameDescription
Public Extension MethodAsParallelEnables parallelization of a query. (Defined by ParallelEnumerable.)
Public Extension MethodAsQueryableConverts an IEnumerable to an IQueryable. (Defined by Queryable.)
Public Extension MethodSupported by the XNA FrameworkCast(TResult)Casts the elements of an IEnumerable to the specified type. (Defined by Enumerable.)
Public Extension MethodSupported by the XNA FrameworkOfType(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 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:

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.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Community Additions

ADD
Show:
© 2015 Microsoft