Adds an entry with the specified key and value into the Hashtable.
[Visual Basic] Overridable Public Sub Add( _ ByVal key As Object, _ ByVal value As Object _ ) [C#] public virtual void Add( object key, object value ); [C++] public: virtual void Add( Object* key, Object* value ); [JScript] public function Add( key : Object, value : Object );
None.
Exception Type | Condition |
---|---|
ArgumentNullException | key is a null reference (in Visual Basic Nothing). |
ArgumentException | An entry with the same key already exists in the Hashtable. |
NotSupportedException | The Hashtable is read-only. |
This method overrides the Add method of the Dictionary class and can itself be overridden by a derived class.
An object that has no correlation between its state and its hash code value should typically not be used as the key. For example, String objects are better than StringBuilder objects for use as keys.
Hashtable Class | Hashtable Members | System.Collections Namespace | Remove | Add