Mega Code Archive

 
Categories / C# / Collections Data Structure
 

Use the Remove method to remove a keyvalue pair

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");         openWith.Remove("A");         if (!openWith.ContainsKey("A"))         {             Console.WriteLine("Key \"A\" is not found.");         }    } }