Gets or sets the value associated with the specified key.
[C#] In C#, this member is the indexer for the Hashtable class.
[Visual Basic] Overridable Public Default Property Item( _ ByVal key As Object _ ) As Object [C#] public object this[ object key ] {virtual get; virtual set;} [C++] public: __property virtual Object* get_Item( Object* key ); public: __property virtual void set_Item( Object* key, Object* ); [JScript] returnValue = HashtableObject.Item(key); HashtableObject.Item(key) = returnValue; -or- returnValue = HashtableObject(key); HashtableObject(key) = returnValue;
[JScript] In JScript, you can use the default indexed properties defined by a type, but you cannot explicitly define your own. However, specifying the expando attribute on a class automatically provides a default indexed Item property whose type is Object and whose index type is String.
The value associated with the specified key. If the specified key is not found, Get returns a null reference (in Visual Basic Nothing), and Set creates a new entry with the specified key.
Exception Type | Condition |
---|---|
ArgumentNullException | key is a null reference (Nothing). |
NotSupportedException | The Hashtable is read-only and Set is attempted. |
Hashtable Class | Hashtable Members | System.Collections Namespace