Share via


Queue Collection Types

The Queue class and the Queue<T> generic class are first-in-first-out collection classes that implement the ICollection interface and the ICollection<T> generic interface.

The Queue and Stack classes, and the Queue<T> and Stack<T> generic classes are useful when you need temporary storage for information, that is, when you might want to discard an element after retrieving its value. Use Queue if you need to access the information in the same order that it is stored in the collection. Use Stack if you need to access the information in reverse order.

Three main operations can be performed on a Queue and its elements:

  • Enqueue adds an element to the end of the Queue.

  • Dequeue removes the oldest element from the start of the Queue.

  • Peek returns the oldest element from the start of the Queue but does not remove it from the Queue.

See Also

Reference

Queue

System.Collections.Generic.Queue<T>

Stack

System.Collections.Generic.Stack<T>

ICollection

System.Collections.Generic.ICollection<T>

Other Resources

Commonly Used Collection Types