Example #1
0
    static void Main1()
    {
        MyCollection collection = new MyCollection();

        foreach (var t in collection)
        {
            int n = (int)t;
            Console.WriteLine(n * n);
        }
        MyCollectionYield collectionYield = new MyCollectionYield();

        foreach (var t in collection)
        {
            int n = (int)t;
            Console.WriteLine(n * n);
        }

        MyCollectionInterface collection2 = new MyCollectionInterface();

        foreach (var t in collection2)
        {
            int n = (int)t;
            Console.WriteLine(n * n);
        }
        IEnumerator e = SaySomething();

        while (e.MoveNext())
        {
            Console.WriteLine(e.Current);
        }
    }
Example #2
0
    static void Main1()
    {
        MyCollection collection = new MyCollection();
        foreach (var t in collection)
        {
            int n = (int)t;
            Console.WriteLine(n * n);
        }
        MyCollectionYield collectionYield = new MyCollectionYield();
        foreach (var t in collection)
        {
            int n = (int)t;
            Console.WriteLine(n * n);
        }

        MyCollectionInterface collection2 = new MyCollectionInterface();
        foreach (var t in collection2)
        {
            int n = (int)t;
            Console.WriteLine(n * n);
        }
        IEnumerator e = SaySomething();
        while (e.MoveNext())
        {
            Console.WriteLine(e.Current);
        }
    }