RankedDictionaryTKey, TValueItem Property |
Namespace: Kaos.Collections
public TValue this[ TKey key ] { get; set; }
Exception | Condition |
---|---|
ArgumentNullException | When key is null. |
KeyNotFoundException | When getting a value and key was not found. |
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.
// 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";