Ejemplo n.º 1
0
        public static void Main()
        {
            try
            {
                Stack<int> stack = new Stack<int>();
                stack.Push(1);
                stack.Push(2);
                stack.Push(3);
                stack.Push(4);
                stack.Push(5);

                int[] array = stack.ToArray();
                Console.WriteLine(string.Join(", ", array));

                Console.WriteLine(stack.Peek());
                Console.WriteLine(stack.Pop());
                Console.WriteLine(stack.Contains(0));
                stack.Clear();
                Console.WriteLine(stack.Peek());
            }
            catch (ArgumentNullException aex)
            {
                Console.WriteLine(aex.TargetSite + " -> " + aex.Message);
            }
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Stack<int> test = new Stack<int>();
            test.Push(1);
            test.Push(2);
            test.Push(3);
            test.Push(4);
            test.Push(5);
            test.Push(6);
            test.Push(7);
            Console.WriteLine(test.Contains(2));

        }