using System; using System.Collections.Generic; public class Test { static IEnumerable infinite(int step = 1, int start = 0) { while (true) yield return start += step; } public static void Main() { foreach (var i in infinite(2, 13)) { if (i > 42) break; Console.WriteLine(i); } } }