Skip to content

Instantly share code, notes, and snippets.

@SriramSakthivel
Created January 30, 2015 21:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SriramSakthivel/fa1bc3936bb91dcbd006 to your computer and use it in GitHub Desktop.
Save SriramSakthivel/fa1bc3936bb91dcbd006 to your computer and use it in GitHub Desktop.
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