VOOZH about

URL: https://www.geeksforgeeks.org/c-sharp/c-sharp-remove-all-elements-from-the-hashtable/

⇱ C# | Remove all elements from the Hashtable - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

C# | Remove all elements 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.Clear Method is used to remove all elements from the Hashtable. Syntax:
myTable.Clear()
Here myTable is the name of the Hashtable. Exceptions: This method will give NotSupportedException if the Hashtable is read-only. Example: Output:
Total number of entries in Hashtable : 4
Total number of entries in Hashtable : 0
Total number of entries in Hashtable : 3
Total number of entries in Hashtable : 0
Reference:
Comment

Explore