METHOD

Queue.TryDequeue

Removes the oldest item on success, returns false if empty.

Formal Syntax & Structure

csharp syntaxcsharp
bool TryDequeue(out T result)

Working Example

Example Snippetcsharp
using System.Collections.Generic;var q = new Queue<int>();System.Console.WriteLine(q.TryDequeue(out _));
C# & .NET Reference