Mega Code Archive

 
Categories / C# / Collections Data Structure
 

Dictionary(TKey, TValue) represents a collection of keys and values

using System; using System.Collections.Generic; public class Example {     public static void Main()     {         Dictionary<string, string> openWith = new Dictionary<string, string>();         openWith.Add("A", "a");         openWith.Add("B", "b");         openWith.Add("C", "c");         try         {             openWith.Add("A", "a");         }         catch (ArgumentException)         {             Console.WriteLine("already exists.");         }     } }