Search notes:

C# yield

using System;
using System.Collections.Generic;

class Prg {

   static IEnumerable<string> words() {
      yield return "foo";
      yield return "bar";
      yield return "baz";
   }

   static void Main() {
      foreach (string word in words()) {
         Console.WriteLine(word);
      }
   }
}
Github repository about-C-Sharp, path: /language/keywords/contextual/yield/simple.cs

See also

System.Collections.IEnumerable, System.Collections.IEnumerator, System.Collections.Generic.IEnumerable<T>, System.Collections.Generic.IEnumerator<T>
The foreach … in statement

Index