ContainsKey can be used to test keys before inserting them
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"); if (!openWith.ContainsKey("W")) { openWith.Add("W", "w"); Console.WriteLine("Value added "); } } }