int[] ints = { 1, 2, 3, 4, 5, 6, 7, 8 }; //Aggregate 第一个参数是用来给计数器total定义初始值的 int nums = ints.Aggregate(0,(total, next) => next % 2 == 0 ? total + 1 : total ) ; Console.WriteLine(nums); Console.ReadLine();
作者:spike
分类: Net
创作时间:2023-06-25
更新时间:2024-12-09