Share via


IDictionary Interface

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Represents a nongeneric collection of key/value pairs.

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

Syntax

'Declaration
Public Interface IDictionary _
    Inherits ICollection, IEnumerable
public interface IDictionary : ICollection, 
    IEnumerable
public interface class IDictionary : ICollection, 
    IEnumerable
type IDictionary =  
    interface
        interface ICollection
        interface IEnumerable
    end
public interface IDictionary extends ICollection, IEnumerable

The IDictionary type exposes the following members.

Properties

  Name Description
Public property Count Gets the number of elements contained in the ICollection. (Inherited from ICollection.)
Public property IsFixedSize Gets a value indicating whether the IDictionary object has a fixed size.
Public property IsReadOnly Gets a value indicating whether the IDictionary object is read-only.
Public property IsSynchronized Gets a value indicating whether access to the ICollection is synchronized (thread safe). (Inherited from ICollection.)
Public property Item Gets or sets the element with the specified key.
Public property Keys Gets an ICollection object containing the keys of the IDictionary object.
Public property SyncRoot Gets an object that can be used to synchronize access to the ICollection. (Inherited from ICollection.)
Public property Values Gets an ICollection object containing the values in the IDictionary object.

Top

Methods

  Name Description
Public method Add Adds an element with the provided key and value to the IDictionary object.
Public method Clear Removes all elements from the IDictionary object.
Public method Contains Determines whether the IDictionary object contains an element with the specified key.
Public method CopyTo Copies the elements of the ICollection to an Array, starting at a particular Array index. (Inherited from ICollection.)
Public method GetEnumerator Returns an enumerator that iterates through a collection. (Inherited from IEnumerable.)
Public method Remove Removes the element with the specified key from the IDictionary object.

Top

Remarks

The IDictionary interface is the base interface for nongeneric collections of key/value pairs.

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.

See Also

Reference

System.Collections Namespace