VOOZH about

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

⇱ C# | SortedDictionary.Clear() Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

C# | SortedDictionary.Clear() Method

Last Updated : 11 Jul, 2025
This method is used to remove all key/value pairs from the SortedDictionary<TKey, TValue>. Syntax:
public void Clear ();
Below are the programs to illustrate the use of the 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