Show
public void Show()
{
if (Rear != -1)
{
Console.WriteLine();
Console.Write("The contents of the queue are: ");
foreach (var item in Contents)
{
Console.Write(item);
}
Console.WriteLine();
}
}
This method first checks that the Rear value is not -1 as an index of -1 would mean the queue is empty, and data cant is take from a queue that is empty.
if (Rear != -1)
The next couple of lines simply print a constant string to the console.
foreach (var item in Contents)
{
Console.Write(item);
}
The above section uses a newly declared variable called item to retrieve a letter from the queue one at a time and print it to the console.