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();
      }
   }
}

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/tech/pnotes/265857.html

(0)
上一篇 2022年6月7日 21:17
下一篇 2022年6月7日 21:17

相关推荐

发表回复

登录后才能评论