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

Syntax

This is the default property for this class.

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

Parameters

key
The key whose value to get or set.

Value

The value in the current instance that is associated with key. If key is not contained in the current instance, attempting to get it returns null, and attempting to set it creates a new entry using key .

Exceptions

TypeReason
ArgumentNullException key is null.
NotSupportedException

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

The property is being set, key is not contained in the current instance, and the current instance has a fixed size.

Remarks

Note: This property provides the ability to access a specific element in the current instance using the following notation: myCollection[key] .

Operation
As described above.

If this property is being set and key is already contained in the current instance, the value associated with the old key is replaced.

Requirements

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