1. 程式人生 > >C# 叠代器

C# 叠代器

ole span app som tput output move next() color

using System;
using System.Collections;
class App{
    public static void Main()
    {
         foreach (int number in SomeNumbers())
         {
             Console.WriteLine(number.ToString() + " ");
         }

        //Console.WriteLine(SomeNumbers().MoveNext());
        // Output: 3 5 8
        
// Console.ReadKey(); } public static IEnumerable SomeNumbers() { yield return 3; yield return 5; yield return 8; } }

C# 叠代器