[C#] C# Aggregate 用法范例 →→→→→进入此内容的聊天室

来自 , 2020-07-10, 写在 C#, 查看 118 次.
URL http://www.code666.cn/view/1138d90e
  1. using System;
  2. using System.Linq;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5.  
  6. public class MainClass {
  7.     public static void Main() {
  8.         int N = 5;
  9.         IEnumerable<int> intSequence = Enumerable.Range(1, N);
  10.         foreach (int item in intSequence)
  11.             Console.WriteLine(item);
  12.         int agg = intSequence.Aggregate((av, e) => av * e);
  13.         Console.WriteLine("{0}! = {1}", N, agg);
  14.  
  15.     }
  16. }
  17.  
  18.  
  19. //csharp/4511

回复 "C# Aggregate 用法范例"

这儿你可以回复上面这条便签

captcha