Represents a nongeneric collection of key/value pairs.
Assembly: mscorlib (in mscorlib.dll)
Thetype exposes the following members.
|Count||Gets the number of elements contained in the ICollection. (Inherited from ICollection.)|
|IsFixedSize||Gets a value indicating whether the object has a fixed size.|
|IsReadOnly||Gets a value indicating whether the object is read-only.|
|IsSynchronized||Gets a value indicating whether access to the ICollection is synchronized (thread safe). (Inherited from ICollection.)|
|Item||Gets or sets the element with the specified key.|
|Keys||Gets an ICollection object containing the keys of the object.|
|SyncRoot||Gets an object that can be used to synchronize access to the ICollection. (Inherited from ICollection.)|
|Values||Gets an ICollection object containing the values in the object.|
|Add||Adds an element with the provided key and value to the object.|
|Clear||Removes all elements from the object.|
|Contains||Determines whether the object contains an element with the specified key.|
|CopyTo||Copies the elements of the ICollection to an Array, starting at a particular Array index. (Inherited from ICollection.)|
|GetEnumerator||Returns an IDictionaryEnumerator object for the object.|
|Remove||Removes the element with the specified key from the object.|
|AsParallel||Enables parallelization of a query. (Defined by ParallelEnumerable.)|
|AsQueryable||Converts an IEnumerable to an IQueryable. (Defined by Queryable.)|
|Cast(TResult)||Casts the elements of an IEnumerable to the specified type. (Defined by Enumerable.)|
|OfType(TResult)||Filters the elements of an IEnumerable based on a specified type. (Defined by Enumerable.)|
The 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 interface allows the contained keys and values to be enumerated, but it does not imply any particular sort order.
implementations fall into three categories: read-only, fixed-size, variable-size. A read-only object cannot be modified. A fixed-size object does not allow the addition or removal of elements, but does allow the modification of existing elements. A variable-size 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 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:
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.
.NET FrameworkSupported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0
.NET Framework Client ProfileSupported in: 4, 3.5 SP1
Portable Class LibrarySupported in: Portable Class Library
.NET for Windows Store appsSupported in: Windows 8
.NET for Windows Phone appsSupported in: Windows Phone 8.1, Windows Phone 8, Silverlight 8.1
Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)