How to remove an item of a Dictionary with C#

Remove Item

The following code snippet creates a Dictionary and adds an item to it by using the Add method.

  1. Dictionary<string, Int16> AuthorList = new Dictionary<string, Int16>();  
  2. AuthorList.Add("Mahesh Chand", 35);  
The Remove method removes an item with the specified key from the collection. The following code snippet removes an item.
  1. // Remove item with key = 'Mahesh Chand'  
  2. AuthorList.Remove("Mahesh Chand");   
The Clear method removes all items from the collection. The following code snippet removes all items by calling the Clear method.
  1. // Remove all items  
  2. AuthorList.Clear();    
Next>> Using Dictionary in C#