Created
October 4, 2011 23:15
-
-
Save einarwh/1263128 to your computer and use it in GitHub Desktop.
Alternative implementation for a positive integer iterator.
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 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