标签:c#
队列(Queue)代表了一个先进先出的对象集合。
using System; using System.Collections; namespace CollectionsApplication { class Program { static void Main(string[] args) { Queue q = new Queue(); q.Enqueue(‘A‘); q.Enqueue(‘M‘); q.Enqueue(‘G‘); q.Enqueue(‘W‘); Console.WriteLine("Current queue: "); foreach (char c in q) Console.Write(c + " "); Console.WriteLine(); q.Enqueue(‘V‘); q.Enqueue(‘H‘); Console.WriteLine("Current queue: "); foreach (char c in q) Console.Write(c + " "); Console.WriteLine(); Console.WriteLine("Removing some values "); char ch = (char)q.Dequeue(); Console.WriteLine("The removed value: {0}", ch); ch = (char)q.Dequeue(); Console.WriteLine("The removed value: {0}", ch); Console.ReadKey(); } } }
参考:
http://www.2cto.com/kf/201505/397750.html
本文出自 “Ricky's Blog” 博客,请务必保留此出处http://57388.blog.51cto.com/47388/1655013
标签:c#
原文地址:http://57388.blog.51cto.com/47388/1655013