System.Collections.Generic.Dictionary<TKey,TValue> Class
Represents a collection of key/value pairs that are organized based on the key.

See Also: Dictionary<TKey,TValue> Members

Syntax

[System.Diagnostics.DebuggerDisplay("Count={Count}")]
[System.Diagnostics.DebuggerTypeProxy(typeof(System.Collections.Generic.CollectionDebuggerView`2))]
[System.Runtime.InteropServices.ComVisible(false)]
public class Dictionary<TKey, TValue> : ICollection<KeyValuePair<TKey, TValue>>, IDictionary<TKey, TValue>, IEnumerable<KeyValuePair<TKey, TValue>>, IReadOnlyCollection<KeyValuePair<TKey, TValue>>, IReadOnlyDictionary<TKey, TValue>, IDictionary, System.Runtime.Serialization.IDeserializationCallback, System.Runtime.Serialization.ISerializable

Type Parameters

TKey
Documentation for this section has not yet been entered.
TValue
Documentation for this section has not yet been entered.

Remarks

Each element is a key/value pair that can be retrieved as a KeyValuePair<TKey, TValue> object.

Dictionary<TKey, TValue> requires an equality comparer implementation to perform comparisons. If no equality comparer is provided, the following default equality comparer approach is used: If type TKey implements IEquatable<TKey>, that implementation is used; otherwise, TKey's implementations of System.Object.Equals(Object) and System.Object.GetHashCode() are used. In any case, you can specify a IEqualityComparer<TKey> implementation in a constructor overload that accepts an equality comparer parameter.

After its insertion in a dictionary, changes to the value of a key that affect the equality comparer render the dictionary's behavior unspecified. Every key in a dictionary must be unique according to the equality comparer. A key cannot be null, but a value can be, if the value type TValue is a reference type.

The capacity of a dictionary is the number of elements that dictionary can hold. As elements are added to a dictionary, the capacity is automatically increased.

This type contains a member that is a nested type, called Enumerator. Although Enumerator is a member of this type, Enumerator is not described here; instead, it is described in its own entry, Dictionary<TKey,TValue>.Enumerator.

Requirements

Namespace: System.Collections.Generic
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0
Since: .NET 2.0