VOOZH about

URL: https://www.geeksforgeeks.org/c-sharp/c-sharp-remove-the-element-with-the-specified-key-from-the-hashtable/

⇱ C# | Remove the element with the specified key from the Hashtable - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

C# | Remove the element with the specified key from the Hashtable

Last Updated : 11 Jul, 2025
The Hashtable class represents a collection of key-and-value pairs that are organized based on the hash code of the key. The key is used to access the items in the collection. Hashtable.Remove(Object) Method is used to remove the element with the specified key from the Hashtable. Syntax:
public virtual void Remove (object key);
Parameter:
key: It is the key of the element to remove of type System.Object.
Exceptions:
  • ArgumentNullException: If the key is null.
  • NotSupportedException: If the Hashtable is read-only or has a fixed size.
Example:
Output:
Total number of entries in Hashtable : 4
Total number of entries in Hashtable : 3
Total number of entries in Hashtable : 2
Total number of entries in Hashtable : 5
Total number of entries in Hashtable : 4
Reference:
Comment

Explore