Пример #1
0
        public Queue arr = new Queue(); //create an object to access this Array
        public static void Main()
        {
            QueueClass obj = new QueueClass();

            obj.arr.Enqueue("Mukundh");
            obj.arr.Enqueue(1);
            obj.arr.Enqueue(1.2);
            obj.arr.Dequeue();
            //Non genric stack ie different data types
            Queue arr2 = new Queue(); //No access sepcifier when declared in main

            arr2.Enqueue("Mukundh");
            arr2.Enqueue(1);
            arr2.Enqueue(1.2);
            arr22.Dequeue();

            //Printing the queue
            foreach (var item in arr2)
            {
                Console.WriteLine(item);
            }
        }
Пример #2
0
        public Queue <int> arr = new Queue <int>(); //create an object to access this Array
        public static void Main()
        {
            //genric stack ie similar datatypes
            QueueClass obj = new QueueClass(); //creating the object for the "ArrayListClass" to access the arraylist

            obj.arr.Enqueue(1);
            obj.arr.Enqueue(2);
            obj.arr.Enqueue(3);
            obj.arr.Dequeue();

            //Non genric stack ie different data types
            Queue <int> arr2 = new Queue <int>(); //No access sepcifier when declared in main

            obj.arr.Enqueue(1);
            obj.arr.Enqueue(2);
            obj.arr.Enqueue(3);
            obj.arr.Dequeue();

            //Printing the queue
            foreach (var item in arr2)
            {
                Console.WriteLine(item);
            }
        }