Click or drag to resize

RankedDictionaryTKey, TValueItem Property

Gets or sets the value associated with the supplied key.

Namespace:  Kaos.Collections
Assembly:  KaosCollections (in KaosCollections.dll) Version: 4.2.0.0
Syntax
Exceptions
ExceptionCondition
ArgumentNullExceptionWhen key is null.
KeyNotFoundExceptionWhen getting a value and key was not found.
Remarks

Setting a value for a non-existent key performs an add operation. To get a value for a supplied index, use the ElementAt(Int32) method.

This is a O(log n) operation for both getting and setting.

Examples
The below snippet is part of a larger example of the RankedDictionaryTKey, TValueclass.
C#
// The indexer can be used to change the value associated with a key.
cc["RU"] = "Russian Federation";

// The indexer can be used to get a value for a key.
Console.WriteLine ($"For key = 'RU', value = {cc["RU"]}.");

// If a key does not exist, setting the indexer for that key
// adds a new key/value pair.
cc["SS"] = "South Sudan";
See Also