Advertisement
Guest User

Pastebin to the Rescue

a guest
Jan 17th, 2011
505
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.37 KB | None | 0 0
  1. static void Main(string[] args)
  2. {
  3.     var index = 0;
  4.     foreach (var result in Hello())
  5.     {
  6.         Console.WriteLine(result);
  7.         index++;
  8.  
  9.         if (index >= 10)
  10.         {
  11.             break;
  12.         }
  13.     }
  14.  
  15.     Console.ReadLine();
  16. }
  17.  
  18. private static IEnumerable<string> Hello()
  19. {
  20.     while (true)
  21.     {
  22.         yield return "Hello World";
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement