Skip to content

Instantly share code, notes, and snippets.

@einarwh
Created October 4, 2011 23:15
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 einarwh/1263128 to your computer and use it in GitHub Desktop.
Save einarwh/1263128 to your computer and use it in GitHub Desktop.
Alternative implementation for a positive integer iterator.
public class ContinuationIncrementer : IEnumerable<int>
{
public IEnumerator<int> GetEnumerator()
{
int n = 0;
while (true)
{
yield return ++n;
}
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment