mscorlib 2.0.0.0 4.0.0.0 System.ValueType System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<TKey,TValue>> System.Collections.IDictionaryEnumerator

The generic class provides a mapping from a set of keys to a set of values. Each addition to the dictionary consists of a value and its associated key. Retrieving a value by using its key is very fast, close to O(1), because the class is implemented as a hash table.

The speed of retrieval depends on the quality of the hashing algorithm of the type specified for .

As long as an object is used as a key in the , it must not change in any way that affects its hash value. Every key in a must be unique according to the dictionary's equality comparer. A key cannot be null, but a value can be, if the value type is a reference type.

requires an equality implementation to determine whether keys are equal. You can specify an implementation of the generic interface by using a constructor that accepts a parameter; if you do not specify an implementation, the default generic equality comparer is used. If type implements the generic interface, the default equality comparer uses that implementation.

For example, you can use the case-insensitive string comparers provided by the class to create dictionaries with case-insensitive string keys.

The capacity of a is the number of elements the can hold. As elements are added to a , the capacity is automatically increased as required by reallocating the internal array.

For very large objects, you can increase the maximum capacity to 2 billion elements on a 64-bit system by setting the enabled attribute of the gcAllowVeryLargeObjects configuration element to true in the run-time environment.

For purposes of enumeration, each item in the dictionary is treated as a structure representing a value and its key. The order in which the items are returned is undefined.

The foreach statement of the C# language (for each in C++, For Each in Visual Basic) requires the type of each element in the collection. Since the is a collection of keys and values, the element type is not the type of the key or the type of the value. Instead, the element type is a of the key type and the value type. For example:

code reference: Generic.Dictionary#11

The foreach statement is a wrapper around the enumerator, which allows only reading from the collection, not writing to it.

Because keys can be inherited and their behavior changed, their absolute uniqueness cannot be guaranteed by comparisons using the method.

Represents a collection of keys and values.

- Property
  2.0.0.0
  4.0.0.0
  System.Collections.Generic.KeyValuePair<TKey,TValue> To be added. To be added. To be added.
- Method
  2.0.0.0
  4.0.0.0
  System.Void To be added. To be added.
- Method
  2.0.0.0
  4.0.0.0
  System.Boolean To be added. To be added. To be added.
- Property
  2.0.0.0
  4.0.0.0
  System.Collections.DictionaryEntry To be added. To be added. To be added.
- Property
  2.0.0.0
  4.0.0.0
  System.Object To be added. To be added. To be added.
- Property
  2.0.0.0
  4.0.0.0
  System.Object To be added. To be added. To be added.
- Property
  2.0.0.0
  4.0.0.0
  System.Object To be added. To be added. To be added.
- Method
  2.0.0.0
  4.0.0.0
  System.Void To be added. To be added.