-
-
Save SriramSakthivel/fa1bc3936bb91dcbd006 to your computer and use it in GitHub Desktop.
Code snippet for the blog post https://sriramsakthivel.wordpress.com/2015/01/30/oh-that-iterators/
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
public class Iterator | |
{ | |
public static void Main(string[] args) | |
{ | |
var numbers = GetGumbers(-1); | |
Console.WriteLine("Program completed successfully"); | |
} | |
private static IEnumerable<int> GetGumbers(int end) | |
{ | |
if (end <= 0) | |
{ | |
throw new ArgumentOutOfRangeException("end", "Parameter 'end' should be greater than zero"); | |
} | |
for (int i = 0; i < end; i++) | |
{ | |
yield return i; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment