Use Aggregate with meaningful variable names in CSharp

Description

The following code shows how to use Aggregate with meaningful variable names.

Example


     //  www  .ja  v a 2s.  c o m
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;


public class MainClass{

   public static void Main(string[] args){   
         Int32[] TestData2 = { 1, 2, 3, 4, 5 };

         var ThisQuery2 =TestData2.Aggregate((ThisElement, Next) => ThisElement + Next);

         Console.WriteLine(ThisQuery2.ToString());
   }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    LINQ »




Operator
Select
Where
OrderBy
Group
Join
Let
LINQ