Queue() Constructor is used to initializes a new instance of the Queue class which will be empty, and will have the default initial capacity, and uses the default growth factor. Queue represents a first-in, first out collection of object. It is used when you need first-in, first-out access of items. When you add an item in the list, it is called enqueue, and when you remove an item, it is called dequeue. This class comes under System.Collections namespace and implements ICollection, IEnumerable, and ICloneable interfaces.
public Queue ();
- The capacity of the Queue represents the number of elements that the Queue can hold. It will increase automatically through reallocation as elements are added to it.
- TrimToSize method is used to decreased the capacity of the Queue.
- When a greater capacity is required then the current capacity is multiplied by a number which is termed as the growth factor.
- This constructor is an O(1) operation.
Before Enqueue Method: 0 After Enqueue Method: 8
- C# | Create a Queue from another collection
- C# | How to create a Stack
- How to create 7-ValueTuple in C#?
- How to create the ArrayList in C#
- How to create 8-ValueTuple in C#?
- How to create 6-ValueTuple in C#?
- How to create the StringBuilder in C#
- How to create 6-Tuple in C#?
- How to create a ListDictionary in C#
- How to create a StringCollection in C#
- How to create 5-ValueTuple in C#?
- How to create 3-ValueTuple in C#?
- How to create 4-ValueTuple in C#?
- How to create 2-ValueTuple in C#?
- How to create a StringDictionary in C#
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.