示例#1
0
        public static void ExampleForEachUsingIteratorMethod()
        {
            var collection = IteratorMethods.GetSingleDigitNumbers();
            IEnumerator <int> enumerator = collection.GetEnumerator();
            var item = default(int);

            while (enumerator.MoveNext())
            {
                item = enumerator.Current;
                Console.WriteLine(item.ToString());
            }
        }
示例#2
0
        public static void Run()
        {
            ForeachExamples.ExampleOne();

            ForeachExamples.ExampleForEachUsingIteratorMethod();

            foreach (var item in IteratorMethods.GetSingleDigitNumbers())
            {
                Console.WriteLine(item);
            }

            foreach (var item in IteratorMethods.GetSingleDigitNumbersV2())
            {
                Console.WriteLine(item);
            }

            foreach (var item in IteratorMethods.GetSingleDigitNumbersAndNumbersOver100())
            {
                Console.WriteLine(item);
            }
        }