VOOZH about

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

⇱ Queue.Clear Method in C# - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Queue.Clear Method in C#

Last Updated : 11 Jul, 2025
This method is used to remove the objects from the Queue. This method is an O(n) operation, where n is the total count of elements. And this method comes under System.Collections namespace. Syntax:
public void Clear ();
Below given are some examples to understand the implementation in a better way: Example 1:
Output:
Total number of elements in the Queue are : 4
Total number of elements in the Queue are : 0
Example 2:
Output:
Total number of elements in the Queue are : 6
Total number of elements in the Queue are : 0
Reference:
Comment

Explore