C# linq Aggregate 用法

 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

联系方式放在中括号之中例如[[email protected]],回复评论在开头加上标号例如:#1