C# 队列(Queue)
程序员文章站
2022-05-22 11:51:14
...
队列(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(); } } }
以上就是C# 队列(Queue)的内容,更多相关内容请关注PHP中文网(www.php.cn)!
上一篇: 详细解读PHP中接口的应用
下一篇: 浅谈非泛型的实例详解