Adds an element with the provided key and value to the IDictionary object.
Type Reason ArgumentNullException key is null. ArgumentException An entry with the same key already exists in the current instance. NotSupportedException The current instance is read-only or has a fixed size.
You can also use the IDictionary.Item(object) property to add new elements by setting the value of a key that does not exist in the dictionary (for example, myCollection["myNonexistentKey"] = myValue). However, if the specified key already exists in the dictionary, setting the IDictionary.Item(object) property overwrites the old value. In contrast, the IDictionary.Add(object, object) method does not modify existing elements.
Implementations can vary in whether they allow the key to be null.