RankedDictionaryTKey, TValueAdd Method |
Namespace: Kaos.Collections
public void Add( TKey key, TValue value )
Exception | Condition |
---|---|
ArgumentNullException | When key is null. |
ArgumentException | When a key/value pair already exists with the supplied key; when no comparer is available. |
If key is already in the dictionary, this method takes no action.
This is a O(log n) operation.
// The Add method throws an exception if the new key is // already in the dictionary. try { cc.Add ("DD", "East Germany"); } catch (ArgumentException) { Console.WriteLine ("An element with Key = 'DD' already exists."); }