You can also use the Item property to add new elements by setting the value of a key that does not exist in the Dictionary<(Of <(TKey, TValue>)>); for example, myCollection[myKey] = myValue (in Visual Basic, myCollection(myKey) = myValue). However, if the specified key already exists in the Dictionary<(Of <(TKey, TValue>)>), setting the Item property overwrites the old value. In contrast, the Add method throws an exception if a value with the specified key already exists.
If the Count property value already equals the capacity, the capacity of the Dictionary<(Of <(TKey, TValue>)>) is increased by automatically reallocating the internal array, and the existing elements are copied to the new array before the new element is added.
A key cannot be nullNothingnullptra null reference (Nothing in Visual Basic), but a value can be, if TValue is a reference type.
If Count is less than the capacity, this method approaches an O(1) operation. If the capacity must be increased to accommodate the new element, this method becomes an O(n) operation, where n is Count.