[C#링크예제]메소드쿼리식에서 Aggregate사용간단예제
					
						꽁스짱					
																
							
							
							C#						
										
					
					0					
					
					2886
															
						
						
							2021.02.15 23:24						
					
				
			[C#링크예제]메소드쿼리식에서 Aggregate사용간단예제
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace LinqAggregationExam
{
    class Program
    {
        static void Main(string[] args)
        {
            //Aggregate는 값을 포워드 하면서 주어진 연산을 수행한다.
            var numbers = new int[] { 1, 2, 3, 4, 5 };
            // 1*2 한 후 결과를 3과 곱하고, 다시 결과를 4와 곱함...
            var result = numbers.Aggregate((a, b) => a * b);
            Console.WriteLine(result);
            // 10은 SEED, 10+1 결과를 2와 더하고 다시 결과를 3과 더함...
            result = numbers.Aggregate(10, (a, b) => a + b);
            Console.WriteLine(result);
        }
    }
}
[결과]
120
25

															
