- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Enqueue and deque in Queue class in C#
Queue collection class is a concept in C# that is included in the System.Collection namespace. The elements are stored in a QUEUE in FIFO. The first element added will be the first to go out like a queue of people outside a movie hall to buy tickets.
It has two methods.
- Enqueue() method to add values
- Dequeue() method to retrieve values
Enqueue
Add items in the queue.
Queue q = new Queue(); q.Enqueue(“Two”); q.Enqueue(“One”);
Dequeue
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());
Advertisements