METHOD

Dictionary indexer

Read retrieves the mapped value or throws for a missing key. Assignment adds or replaces.

Formal Syntax & Structure

csharp syntaxcsharp
dictionary[key]

Working Example

Example Snippetcsharp
using System.Collections.Generic;var map = new Dictionary<int,int>();map[1] = 4;System.Console.WriteLine(map[1]);
C# & .NET Reference