Home > Backend Development > C#.Net Tutorial > Enqueue and deque in C# Queue class

Enqueue and deque in C# Queue class

PHPz
Release: 2023-09-06 19:09:10
forward
1417 people have browsed it

C# Queue 类中的入队和双端队列

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.

  • Enqueue() method adds value
  • Dequeue() method for retrieving values

Enter the team

Add items to the queue.

Queue q = new Queue();
q.Enqueue(“Two”);
q.Enqueue(“One”);
Copy after login

Departure

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());
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template