Beispiel #1
0
        public static void Main(string[] args)
        {
            GenericStack <int> ints = new GenericStack <int>();

            ints.Push(5);
            ints.Push(6);
            ints.Push(7);
            ints.Push(8);

            foreach (int x in ints)
            {
            }

            var multiples =
                from i in ints
                where i % 5 == 0
                select i * i;
        }
Beispiel #2
0
        public static void Main(string[] args)
        {
            GenericStack <int> s = new GenericStack <int>();

            s.Push(100);
            s.Push(50);
            s.Push(-12);
            s.Push(37);

            // s is IEnumerable, so I can use foreach:
            foreach (int x in s)
            {
                Console.WriteLine(x);                 // FILO order. Does not modify the stack.
            }

            // I can also use LINQ!
            var multiples =
                from v in s
                where v % 10 == 0
                select v;
        }
Beispiel #3
0
 public GenericStackEnumerator(GenericStack <TData> stack)
 {
     mStack = stack;
     mIndex = mStack.Count;
 }