ConcurrentQueuequeue = new ConcurrentQueue (); queue.Enqueue(10); queue.Enqueue(20); queue.Enqueue(30);
if (queue.TryDequeue(out int result)) { Console.WriteLine(result); }In the first example, we create a new ConcurrentQueue instance and add three integers to it using Enqueue operation. In the second example, we try to Dequeue an item from the queue and if successful, print the value of the item. The package library for ConcurrentQueue is System.Collections.Concurrent.