Created
March 5, 2020 22:54
-
-
Save FrankKerrigan/dff174c266f5d737eb7f07e3c261a4e6 to your computer and use it in GitHub Desktop.
C# Simple Yeild
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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