VOOZH about

URL: https://www.geeksforgeeks.org/c-sharp/c-sharp-dictionary-clear-method/

⇱ C# | Dictionary.Clear Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

C# | Dictionary.Clear Method

Last Updated : 11 Jul, 2025
This method is used to remove all key/value pairs from the Dictionary<TKey,TValue>. Syntax:
public void Clear ();
Below are the programs to illustrate the use of above-discussed method: Example 1:
Output:
Total key/value pairs in myDict are : 6
After clear operation
Total key/value pairs in myDict are : 0
Example 2:
Output:
Total key/value pairs in myDict are : 4
After clear operation
Total key/value pairs in myDict are : 0
Reference:
Comment

Explore