using System;
using System.Collections;
class Program
{
static void Main()
{
Queue q = new Queue();
Console.WriteLine("Add Numbers to the Q");
foreach (int n in new int[3] { 1, 2, 3 })
{
q.Enqueue(n);
Console.WriteLine(n);
}
Console.WriteLine("Display Numbers from the Q");
foreach (int n in q)
{
Console.WriteLine(n);
}
Console.WriteLine("Remove Numbers from the Q");
while (q.Count != 0)
{
int n = (int)q.Dequeue();
Console.WriteLine(n);
}
Console.ReadKey();
}
}
|
Imports System.Collections
Class Program
Private Shared Sub Main()
Dim q As New Queue()
Console.WriteLine("Add Numbers to the Q")
For Each n As Integer In New Integer(2) {1, 2, 3}
q.Enqueue(n)
Console.WriteLine(n)
Next
Console.WriteLine("Display Numbers from the Q")
For Each n As Integer In q
Console.WriteLine(n)
Next
Console.WriteLine("Remove Numbers from the Q")
While q.Count <> 0
Dim n As Integer = CInt(q.Dequeue())
Console.WriteLine(n)
End While
Console.ReadKey()
End Sub
End Class
|