Skip to content

Instantly share code, notes, and snippets.

@FrankKerrigan
Created March 5, 2020 22:54
Show Gist options
  • Save FrankKerrigan/dff174c266f5d737eb7f07e3c261a4e6 to your computer and use it in GitHub Desktop.
Save FrankKerrigan/dff174c266f5d737eb7f07e3c261a4e6 to your computer and use it in GitHub Desktop.
C# Simple Yeild
using System;
using System.Collections.Generic;
namespace Yield
{
class Program
{
static void Main(string[] args)
{
foreach (var number in GetNumbers())
{
Console.WriteLine($"Account Number: {number}" );
}
}
private static IEnumerable<int> GetNumbers()
{
yield return 1;
yield return 2;
yield return 3;
yield return 4;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment