Posted By

yesraaj on 01/04/11


Tagged

numbers function in given range generates


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

thastyle
Priestd09


Range in c#


 / Published in: C#
 

  1. class util
  2. {
  3. public static IEnumerable<int> Range(int min, int max)
  4. {
  5. while (true)
  6. {
  7. if (min >= max)
  8. {
  9. yield break;
  10. }
  11. yield return min++;
  12. }
  13. }
  14. }
  15.  
  16. //Usage
  17. foreach (int notToUseVariable in util.Range(0,10))
  18. {
  19. btn[notToUseVariable] = notToUseVariable.ToString();
  20. }

Report this snippet  

You need to login to post a comment.