Dictionary<TKey, TValue>

The .NET collection that maps unique keys to values and finds a value by its key in constant time by hashing the key.

In more detail

Reading a missing key with the indexer throws, so use ContainsKey or TryGetValue when absence is normal. Keys must not change their hash code while stored.

Example

var prices = new Dictionary<string, decimal> { ["Kettle"] = 24.50m };

Related terms

Taught in

References