Click or drag to resize

RankedDictionaryTKey, TValueAdd Method

Adds an element with the supplied key and value.

Namespace:  Kaos.Collections
Assembly:  KaosCollections (in KaosCollections.dll) Version: 4.2.0.0
Syntax
Exceptions
ExceptionCondition
ArgumentNullExceptionWhen key is null.
ArgumentException When a key/value pair already exists with the supplied key; when no comparer is available.
Remarks

If key is already in the dictionary, this method takes no action.

This is a O(log n) operation.

Examples
The below snippet is part of a larger example of the RankedDictionaryTKey, TValueclass.
C#
// 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.");
}
See Also