Mono Class Library: System.Collections.Generic.IDictionary<TKey,TValue> Overview | Members

System.Collections.Generic.IDictionary<TKey,TValue>.Item Property

Gets or sets the element in the current instance that is associated with the specified key.

This is the default property for this class.

public TValue this [TKey key] { set; get; }

Parameters

key
The key of the element to get or set.

Value

The value associated with the given key.

Exceptions

TypeReason
ArgumentExceptionThe property is read but key is not found.
NotSupportedExceptionThe property is set and the current instance is read-only.

Remarks

This property provides the ability to access a specific element in the collection.

You can also use the IDictionary<TKey, TValue>.Item(TKey)(TKey) property to add new elements by setting the value of a key that does not exist in the dictionary. However, if the specified key already exists in the dictionary, setting the IDictionary<TKey, TValue>.Item(TKey)(TKey) property overwrites the old value. In contrast, the IDictionary<TKey, TValue>.Add(TKey, TValue)(TKey,TValue) method does not modify existing elements.

Implementations can vary in how they determine equality of objects.

Requirements

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