弹指一挥间

好好做事,学习待人 (大数据分析/.NET/JAVA)技术交流QQ:860280456; .NET/JAVA技术交流群:192028174

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

using System;
using System.Collections.Generic;
using System.Text;
using System.Collections.Specialized;
using System.Collections;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            TestQueue();
            TestStack();
            Console.Read();
        }
        private static void TestQueue()
        {
            Queue queue = new Queue();
            queue.Enqueue(5);
            queue.Enqueue(7);
            queue.Enqueue(9);

            Int32 count = queue.Count;

            //output 5, 7, 9
            for (Int32 index = 0; index < count; ++index)
            {
                Console.Write(" " + ((Int32)queue.Dequeue()).ToString());// MessageBox.Show();
            }
        }

        public static void TestStack()
        {
            Stack stack = new Stack();
            stack.Push(5);
            stack.Push(7);
            stack.Push(9);

            Int32 count = stack.Count;

            //output 9, 7, 5
            for (Int32 index = 0; index < count; ++index)
            {
                Console.Write(" " + ((Int32)stack.Pop()).ToString());
            }
        }

    }
}
 

posted on 2010-03-29 15:40  v.e.n.u.s  阅读(152)  评论(0)    收藏  举报