static void Main(string[] args) { IEnumerable <int> list = new GetRandomNumbersClass(10); IEnumerator <int> rator = list.GetEnumerator(); try { while (rator.MoveNext()) { Console.WriteLine(rator.Current); } } finally { rator.Dispose(); } }
static IEnumerable <int> GetRandomNumbers(int count) { GetRandomNumbersClass grn = new GetRandomNumbersClass(count); return(grn); }