class Program
    {
        static void Main(string[] args)
        {
            //先进先出
            string[] cars = new string[] { "宝马", "奔驰", "奥迪", "东风", "劳斯莱斯" };
            Queue<string> aa = new Queue<string>();
            Console.WriteLine("开始入队列:");
            foreach (var item in cars)
            {
                aa.Enqueue(item);
                Console.WriteLine(item);
                Console.WriteLine("入队列-{0}",item);
            }
            Console.WriteLine();
            PrintQueue(aa);
            Console.WriteLine();

            Console.WriteLine("开始出队列:");



            while (aa.Count>0)
            {
                string str = aa.Dequeue();
            }
            Console.ReadKey();
        }
        private static void PrintQueue(Queue<string> list)
        {
            Console.WriteLine("开始打印队列:");
            foreach (string str in list)
            {
                Console.WriteLine(str);
            }
        }
    }
posted on 2019-11-05 15:10  .net之路  阅读(79)  评论(0编辑  收藏  举报