Skip to content

Instantly share code, notes, and snippets.

@TryJSIL
Created May 27, 2012 08:52

Revisions

  1. TryJSIL created this gist May 27, 2012.
    17 changes: 17 additions & 0 deletions Yield.cs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    using System;
    using System.Collections;
    using System.Collections.Generic;

    public static class Program {
    public static IEnumerable<int> OneToNine {
    get {
    for (int i = 0; i < 10; i++)
    yield return i;
    }
    }

    public static void Main (string[] args) {
    foreach (var i in OneToNine)
    Console.WriteLine("{0}", i);
    }
    }