ListDictionary.Remove(Object) method is used to remove the entry with the specified key from the ListDictionary.
public void Remove (object key);
Here, key is the key of the entry which is to be removed.
Exception: This method will give ArgumentNullException if the key is null.
Below are the examples to illustrate the use of ListDictionary.Remove(Object) Method:
Total key/value pairs in myDict are : 6 The key/value pairs in myDict are : Australia Canberra Belgium Brussels Netherlands Amsterdam China Beijing Russia Moscow India New Delhi Total key/value pairs in myDict are : 5 The key/value pairs in myDict are : Australia Canberra Belgium Brussels Netherlands Amsterdam China Beijing India New Delhi
Example 2 :
System.ArgumentNullException: Key cannot be null.
Parameter name: key
- If the ListDictionary does not contain an element with the specified key, the ListDictionary remains unchanged. No exception is thrown.
- This method is an O(n) operation, where n is Count.
- C# | Remove entry with specified key from OrderedDictionary
- C# | Remove entry with specified key from the StringDictionary
- C# | Remove all entries from the ListDictionary
- C# | Remove the entry at specified index from OrderedDictionary
- C# | Add the specified key and value into the ListDictionary
- C# | Get or set the value associated with specified key in ListDictionary
- C# | Insert a new entry in OrderedDictionary with specified key and value
- C# | Removing the specified key entry from HybridDictionary
- C# | ListDictionary Class
- How to create a ListDictionary in C#
- C# | Get an ICollection containing the values in ListDictionary
- C# | Check if ListDictionary contains a specific key
- C# | Check if ListDictionary is read-only
- C# | Get an enumerator that iterates through the ListDictionary
- How to get Synchronize access to the ListDictionary in C#
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.