HybridDictionary.Add Method (Object, Object)
Adds an entry with the specified key and value into the HybridDictionary.
Assembly: System (in System.dll)
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.
A key cannot be null, but a value can.
You can also use the Item property to add new elements by setting the value of a key that does not exist in the HybridDictionary; for example, myCollection["myNonexistentKey"] = myValue. However, if the specified key already exists in the HybridDictionary, setting the Item property overwrites the old value. In contrast, the method does not modify existing elements.
When the number of elements becomes greater than the optimal size for a ListDictionary, the elements are copied from the ListDictionary to a Hashtable. However, this only happens once. If the collection is already stored in a Hashtable and the number of elements falls below the optimal size for a ListDictionary, the collection remains in the Hashtable.
This method is an O(1) operation.
Available since 10
Available since 1.1