using System; using System.Collections.Generic; using System.Text; using System.Collections; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { Queue qu = new Queue(); Queue qu2 = new Queue(); foreach (int i in new int[4] { 1, 2, 3, 4 }) { qu.Enqueue(i);//入队 qu2.Enqueue(i); } foreach (int i in qu) { Console.WriteLine(i);//遍历 } qu.Dequeue();//出队 Console.WriteLine("Dequeue"); foreach (int i in qu) { Console.WriteLine(i); } qu2.Peek();//返回位于 Queue 开始处的对象但不将其移除。 Console.WriteLine("Peek"); foreach (int i in qu2) { Console.WriteLine(i); } } } }