Advertisement
NPSF3000

SimpleIEnumerable

Aug 1st, 2012
661
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.49 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace SimpleIEnumerable
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             foreach (var random in RandomNum(10, 10)) Console.WriteLine(random);
  11.             Console.ReadLine();
  12.         }
  13.  
  14.         static Random rnd = new Random();
  15.         static IEnumerable<int> RandomNum(int max, int count)
  16.         {
  17.             for (int i = 0; i < count; i++) yield return rnd.Next(max);
  18.         }
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement