System.Collections.IDictionary.Item Property
Gets or sets the element in the current instance that is associated with the specified key.

Syntax

This is the default property for this class.

public object this [object key] { get; set; }

Parameters

key
The key of the element to get or set.

Value

The element with the specified key.

Exceptions

TypeReason
ArgumentNullException key is null.
NotSupportedException

The property is set and the current instance is read-only.

The property is set, key does not exist in the collection, and the current instance has a fixed size.

Remarks

Note: This property provides the ability to access a specific element in the collection by using the following syntax: myCollection[index].

Operation

When setting this property, if the specified key already exists in the current instance, the value is required to be replaced; otherwise, a new element is required to be created.

Requirements

Namespace: System.Collections
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0