Home > Article > Backend Development > Enqueue and deque in C# Queue class
The queue collection class is a concept in C# and is included in the System.Collection namespace. Elements are stored in a FIFO queue. The first element added will be the first one out, like people queuing up outside a movie theater to buy tickets.
It has two methods.
Add items to the queue.
Queue q = new Queue(); q.Enqueue(“Two”); q.Enqueue(“One”);
Return items from the queue.
Queue q = new Queue(); q.Enqueue(“Two”); q.Enqueue(“One”); // remove elements while (q.Count > 0) Console.WriteLine(q.Dequeue());
The above is the detailed content of Enqueue and deque in C# Queue class. For more information, please follow other related articles on the PHP Chinese website!