Join Nostr
2026-10-26 19:08:02 UTC

codementor on Nostr: Learn: Queue<T>: first in, first out A queue gives items back in the order they came ...

Learn: Queue<T>: first in, first out

A queue gives items back in the order they came in. Enqueue adds at the back, Dequeue removes from the front, and Peek looks at the front without removing it.

```csharp
var q = new Queue<string>();
q.Enqueue("first"); q.Enqueue("second");
Console.WriteLine(q.Peek());
Console.WriteLine(q.Dequeue() + " " + q.Dequeue());
```

It prints first, then first second.

Queues are the tool for "handle in order of arrival": jobs, messages, and breadth-first search.

#sq006 · SQ-006-N