using System.Threading; namespace ConsoleApp57 { internal class Program { static void Main(string[] args) { PrintNumers(); Console.WriteLine("Hello, World!"); } static void PrintNumers() { var nums = GenEvenNumbers(); foreach (var i in nums) { Console.WriteLine($"{i},{DateTime.Now.ToString("yyyyMMddHHmmss")}"); } } static IEnumerable<int> GenEvenNumbers() { IEnumerable<int> arr = Enumerable.Range(0, Int32.MaxValue); foreach (int i in arr) { if(i%2==0) { yield return i; Thread.Sleep(1000); } } } } }
标签:arr,Console,keyword,congest,C#,IEnumerable,yield,static,consume From: https://www.cnblogs.com/Fred1987/p/18383248