public void Add(
TKey key,
TValue value
)
Public Sub Add (
key As TKey,
value As TValue
)
public:
virtual void Add(
TKey key,
TValue value
) sealed
abstract Add :
key : 'TKey *
value : 'TValue -> unit
override Add :
key : 'TKey *
value : 'TValue -> unit
If the key of element already exists in the dictionary, this method throws an exception. In contrast, using the setter of the indexer property replaces the old value with the new one.
If multiple values are added to this ThreadSafeDictionaryTKey, TValue concurrently, then you should use the TryAdd method instead, which simply returns if the key to add already exists in the dictionary.
ArgumentNullException | key is . |
ArgumentException | key already exists in the dictionary. |