In this program, we are inserting 4 items into queue, then getting items from queue without removing them, using Peek() method, so that we always got same item.
Note: In above program, to use 'Queue' class, we need to include System.Collection namespace.
Program to peek elements from Queue C#
Output
In this program, we are inserting 4 items into queue, then getting items from queue without removing them, using Peek() method, so that we always got same item.
Note: In above program, to use 'Queue' class, we need to include System.Collection namespace.