{"id":1039,"date":"2023-03-18T09:15:16","date_gmt":"2023-03-18T02:15:16","guid":{"rendered":"https:\/\/csharptutorial.net\/?page_id=1039"},"modified":"2023-06-25T20:18:24","modified_gmt":"2023-06-25T13:18:24","slug":"linq-aggregate","status":"publish","type":"page","link":"https:\/\/www.csharptutorial.net\/csharp-linq\/linq-aggregate\/","title":{"rendered":"LINQ Aggregate"},"content":{"rendered":"\n<p><strong>Summary<\/strong>: in this tutorial, you&#8217;ll learn how to use the LINQ <code>Aggregate()<\/code> method to perform a cumulative operation on a sequence.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Introduction to the LINQ Aggregate() method<\/h2>\n\n\n\n<p>The <code>Aggregate()<\/code> method performs an operation on each element of a sequence, taking into account the result of the previous operation. <\/p>\n\n\n\n<p>The <code>Aggregate()<\/code> method starts by performing an operation on the first and second elements in the sequence and then carries the result forward. Then, it operates on the previous result and third element and carries the result forward. <\/p>\n\n\n\n<p>The <code>Aggregate()<\/code> method continues this process for all the remaining elements in the sequence. By the end, it combines all elements into a single result based on the operation performed at each step.<\/p>\n\n\n\n<p>Here&#8217;s the syntax of the LINQ <code>Aggregate()<\/code> method:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"C#\" data-shcb-language-slug=\"cs\"><span><code class=\"hljs language-cs\"><span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">static<\/span> TSource Aggregate&lt;TSource&gt;(\n    <span class=\"hljs-keyword\">this<\/span> IEnumerable&lt;TSource&gt; source, \n    Func&lt;TSource, TSource, TSource&gt; func\n);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">C#<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">cs<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In this syntax:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>source <\/code>is the input sequence that has the type of <code><a href=\"https:\/\/csharptutorial.net\/csharp-linq\/csharp-ienumerable\/\">Enumerable&lt;T&gt;<\/a><\/code>.<\/li>\n\n\n\n<li><code>func<\/code> &#8211; a <a href=\"https:\/\/csharptutorial.net\/csharp-tutorial\/csharp-lambda-expression\/\">lambda expression<\/a> that performs the operation on elements of the sequence.<\/li>\n<\/ul>\n\n\n\n<p>The lambda expression takes two parameters:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>An accumulator that stores the result of the previous operation.<\/li>\n\n\n\n<li>The current value of the sequence.<\/li>\n<\/ul>\n\n\n\n<p>The <code>Aggregate()<\/code> method has an overload that accepts a seed value as follows:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"C#\" data-shcb-language-slug=\"cs\"><span><code class=\"hljs language-cs\"><span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">static<\/span> TResult Aggregate&lt;TSource,TAccumulate,TResult&gt; (\n    IEnumerable&lt;TSource&gt; source, \n    TAccumulate seed, \n    Func&lt;TAccumulate,TSource,TAccumulate&gt; func\n);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">C#<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">cs<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In this syntax, the <code>Aggregate()<\/code> method starts operating on the seed value with the first element and carries the result forward.<\/p>\n\n\n\n<p>In case you want to transform the result, you can pass the <code>resultSelector<\/code> function to the <code>Aggregate()<\/code> method as follows:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"C#\" data-shcb-language-slug=\"cs\"><span><code class=\"hljs language-cs\"><span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">static<\/span> TResult Aggregate&lt;TSource,TAccumulate,TResult&gt; (\n    IEnumerable&lt;TSource&gt; source, \n    TAccumulate seed, \n    Func&lt;TAccumulate,TSource,TAccumulate&gt; func, \n    Func&lt;TAccumulate,TResult&gt; resultSelector\n);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">C#<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">cs<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In this syntax, the <code>resultSelector<\/code> transforms the final accumulator value into the result value.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">LINQ Aggregate() method examples<\/h2>\n\n\n\n<p>Let&#8217;s take some examples of using the <code>Aggregate()<\/code> method.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1) Using LINQ Aggregate() to calculate the sum of numbers<\/h3>\n\n\n\n<p>The following example demonstrates how to use the LINQ <code>Aggregate()<\/code> method to calculate the sum of numbers of a list:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"C#\" data-shcb-language-slug=\"cs\"><span><code class=\"hljs language-cs\"><span class=\"hljs-keyword\">using<\/span> <span class=\"hljs-keyword\">static<\/span> System.Console;\n\nList&lt;<span class=\"hljs-keyword\">int<\/span>&gt; numbers = <span class=\"hljs-keyword\">new<\/span>() { <span class=\"hljs-number\">1<\/span>, <span class=\"hljs-number\">2<\/span>, <span class=\"hljs-number\">3<\/span>, <span class=\"hljs-number\">4<\/span>, <span class=\"hljs-number\">5<\/span> };\n<span class=\"hljs-keyword\">var<\/span> step = <span class=\"hljs-number\">0<\/span>;\n\n<span class=\"hljs-keyword\">int<\/span> result = numbers.Aggregate((acc, current) =&gt;\n{\n    step++;\n    <span class=\"hljs-keyword\">var<\/span> sum = acc + current;\n    WriteLine(<span class=\"hljs-string\">$\"Step <span class=\"hljs-subst\">{step}<\/span>: acc=<span class=\"hljs-subst\">{acc}<\/span>, current=<span class=\"hljs-subst\">{current}<\/span>, sum=<span class=\"hljs-subst\">{sum}<\/span>\"<\/span>);\n    <span class=\"hljs-keyword\">return<\/span> sum;\n});<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">C#<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">cs<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Output:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"C#\" data-shcb-language-slug=\"cs\"><span><code class=\"hljs language-cs\">Step <span class=\"hljs-number\">1<\/span>: acc=<span class=\"hljs-number\">1<\/span>, current=<span class=\"hljs-number\">2<\/span>, sum=<span class=\"hljs-number\">3<\/span>\nStep <span class=\"hljs-number\">2<\/span>: acc=<span class=\"hljs-number\">3<\/span>, current=<span class=\"hljs-number\">3<\/span>, sum=<span class=\"hljs-number\">6<\/span>\nStep <span class=\"hljs-number\">3<\/span>: acc=<span class=\"hljs-number\">6<\/span>, current=<span class=\"hljs-number\">4<\/span>, sum=<span class=\"hljs-number\">10<\/span>\nStep <span class=\"hljs-number\">4<\/span>: acc=<span class=\"hljs-number\">10<\/span>, current=<span class=\"hljs-number\">5<\/span>, sum=<span class=\"hljs-number\">15<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">C#<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">cs<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>How it works.<\/p>\n\n\n\n<p>First, define a list that has five numbers from 1 to 5:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"C#\" data-shcb-language-slug=\"cs\"><span><code class=\"hljs language-cs\">List&lt;<span class=\"hljs-keyword\">int<\/span>&gt; numbers = <span class=\"hljs-keyword\">new<\/span>() { <span class=\"hljs-number\">1<\/span>, <span class=\"hljs-number\">2<\/span>, <span class=\"hljs-number\">3<\/span>, <span class=\"hljs-number\">4<\/span>, <span class=\"hljs-number\">5<\/span> };<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">C#<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">cs<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Second, define a variable that step and initialize it to zero:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"C#\" data-shcb-language-slug=\"cs\"><span><code class=\"hljs language-cs\"><span class=\"hljs-keyword\">var<\/span> step = <span class=\"hljs-number\">0<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">C#<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">cs<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Third, use the <code><code>Aggregate()<\/code><\/code> method to perform a cumulative sum on the list. The lambda expression specified in the <code><code>Aggregate()<\/code><\/code> method adds two numbers and returns the total. In addition, the lambda expression increments the step variable and writes the current value of acc, current, and sum to the console:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"C#\" data-shcb-language-slug=\"cs\"><span><code class=\"hljs language-cs\"><span class=\"hljs-keyword\">int<\/span> result = numbers.Aggregate((acc, current) =&gt;\n{\n    step++;\n    <span class=\"hljs-keyword\">var<\/span> sum = acc + current;\n    WriteLine(<span class=\"hljs-string\">$\"Step <span class=\"hljs-subst\">{step}<\/span>: acc=<span class=\"hljs-subst\">{acc}<\/span>, current=<span class=\"hljs-subst\">{current}<\/span>, sum=<span class=\"hljs-subst\">{sum}<\/span>\"<\/span>);\n    <span class=\"hljs-keyword\">return<\/span> sum;\n});<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">C#<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">cs<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The <code><code>Aggregate()<\/code><\/code> method starts with two elements of the numbers list and adds them up to return 3. The <code><code>Aggregate()<\/code><\/code> method then takes 3 and adds it to the next number of the list (3) to get 6. The method repeats this process for the remaining elements. It returns the final result of 15.<\/p>\n\n\n\n<p>The following program simplified the above program without writing the immediate results to the console:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"C#\" data-shcb-language-slug=\"cs\"><span><code class=\"hljs language-cs\"><span class=\"hljs-keyword\">using<\/span> <span class=\"hljs-keyword\">static<\/span> System.Console;\n\nList&lt;<span class=\"hljs-keyword\">int<\/span>&gt; numbers = <span class=\"hljs-keyword\">new<\/span>() { <span class=\"hljs-number\">1<\/span>, <span class=\"hljs-number\">2<\/span>, <span class=\"hljs-number\">3<\/span>, <span class=\"hljs-number\">4<\/span>, <span class=\"hljs-number\">5<\/span> };\n\n<span class=\"hljs-keyword\">int<\/span> result = numbers.Aggregate((acc, current) =&gt; acc + current);\n\nWriteLine(result);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">C#<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">cs<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Notice that the purpose of this program is to help you understand how the <code>Aggregate()<\/code> works. In practice, you should use the <code>Sum()<\/code> function instead.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2) Using LINQ Aggregate() with a seed value<\/h3>\n\n\n\n<p>The following program demonstrates how to use the LINQ <code>Aggregate()<\/code> method with a seed value to multiply all numbers in a list:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-10\" data-shcb-language-name=\"C#\" data-shcb-language-slug=\"cs\"><span><code class=\"hljs language-cs\"><span class=\"hljs-keyword\">using<\/span> <span class=\"hljs-keyword\">static<\/span> System.Console;\n\n<span class=\"hljs-keyword\">var<\/span> numbers = <span class=\"hljs-keyword\">new<\/span> List&lt;<span class=\"hljs-keyword\">int<\/span>&gt; { <span class=\"hljs-number\">1<\/span>, <span class=\"hljs-number\">2<\/span>, <span class=\"hljs-number\">3<\/span>, <span class=\"hljs-number\">4<\/span>, <span class=\"hljs-number\">5<\/span> };\n<span class=\"hljs-keyword\">var<\/span> product = numbers.Aggregate(<span class=\"hljs-number\">10<\/span>, (acc, current) =&gt; acc * current);\n\nWriteLine(product);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-10\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">C#<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">cs<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Output:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-11\" data-shcb-language-name=\"C#\" data-shcb-language-slug=\"cs\"><span><code class=\"hljs language-cs\"><span class=\"hljs-number\">1200<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-11\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">C#<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">cs<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In this example, we use the <code>Aggregate()<\/code> method to multiply all numbers in the numbers list and return the result.<\/p>\n\n\n\n<p>The <code>Aggregate()<\/code> method starts with a seed value (10) and multiplies it by the first number of the numbers list, which results in 10.<\/p>\n\n\n\n<p>The <code>Aggregate()<\/code> method then multiplies the result (10) by the next element in the list (2) to get 20.<\/p>\n\n\n\n<p>The <code>Aggregate()<\/code> method repeats this process for the remaining numbers of the list until it has multiplied all the numbers together and returned the final result of 1200.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3) Using the LINQ Aggregate() method with a resultSelector function<\/h3>\n\n\n\n<p>The following example demonstrates how to use the LINQ <code>Aggregate()<\/code> method with a result selector function:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-12\" data-shcb-language-name=\"C#\" data-shcb-language-slug=\"cs\"><span><code class=\"hljs language-cs\">\nList&lt;<span class=\"hljs-keyword\">string<\/span>&gt; words = <span class=\"hljs-keyword\">new<\/span>() {<span class=\"hljs-string\">\"simple\"<\/span>, <span class=\"hljs-string\">\"is\"<\/span>, <span class=\"hljs-string\">\"better\"<\/span>, <span class=\"hljs-string\">\"than\"<\/span>, <span class=\"hljs-string\">\"complex\"<\/span> };\n\n<span class=\"hljs-keyword\">string<\/span> sentence = words.Aggregate(\n    <span class=\"hljs-string\">\"\"<\/span>,\n    (acc, word) =&gt; { <span class=\"hljs-keyword\">return<\/span> acc != <span class=\"hljs-keyword\">string<\/span>.Empty ? acc + <span class=\"hljs-string\">\" \"<\/span> + word : word; },\n    acc =&gt; acc.ToUpper()\n);\n\nConsole.WriteLine(sentence);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-12\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">C#<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">cs<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Output:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-13\" data-shcb-language-name=\"C#\" data-shcb-language-slug=\"cs\"><span><code class=\"hljs language-cs\">SIMPLE IS BETTER THAN COMPLEX<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-13\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">C#<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">cs<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>How it works.<\/p>\n\n\n\n<p>First, define a list that has five strings.<\/p>\n\n\n\n<p>Second, use the <code>Aggregate()<\/code> method to concatenate all the strings in the list, separated by spaces, and convert the final accumulator into upper case.<\/p>\n\n\n\n<p>The first lambda expression takes two parameters <code>acc<\/code> and word that represents the accumulator and current element being processed respectively:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-14\" data-shcb-language-name=\"C#\" data-shcb-language-slug=\"cs\"><span><code class=\"hljs language-cs\">(acc, word) =&gt;\n{\n    <span class=\"hljs-keyword\">return<\/span> acc != <span class=\"hljs-keyword\">string<\/span>.Empty ? acc + <span class=\"hljs-string\">\" \"<\/span> + word : word;\n}<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-14\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">C#<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">cs<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>It concatenates the current string element with the accumulator, separated by a space if the accumulator is not empty, and returns the result as an accumulator. <\/p>\n\n\n\n<p>The second lambda expression takes a single parameter <code>acc<\/code> that represents the final accumulator value. It converts that value to uppercase and returns it as the final result of the <code>Aggregate()<\/code> method:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-15\" data-shcb-language-name=\"C#\" data-shcb-language-slug=\"cs\"><span><code class=\"hljs language-cs\">acc =&gt; acc.ToUpper()<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-15\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">C#<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">cs<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Summary<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use the <code>Aggregate()<\/code> method to perform an operation on the first and second elements and carry the result forward.<\/li>\n<\/ul>\n<div class=\"helpful-block-content\" data-title=\"\">\n\t<header>\n\t\t<div class=\"wth-question\">Was this tutorial helpful ?<\/div>\n\t\t<div class=\"wth-thumbs\">\n\t\t\t<button\n\t\t\t\tdata-post=\"1039\"\n\t\t\t\tdata-post-url=\"https:\/\/www.csharptutorial.net\/csharp-linq\/linq-aggregate\/\"\n\t\t\t\tdata-post-title=\"LINQ Aggregate\"\n\t\t\t\tdata-response=\"1\"\n\t\t\t\tclass=\"wth-btn-rounded wth-yes-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t\tclass=\"feather feather-thumbs-up block w-full h-full\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> Yes <\/span>\n\t\t\t<\/button>\n\n\t\t\t<button\n\t\t\t\tdata-response=\"0\"\n\t\t\t\tdata-post=\"1039\"\n\t\t\t\tdata-post-url=\"https:\/\/www.csharptutorial.net\/csharp-linq\/linq-aggregate\/\"\n\t\t\t\tdata-post-title=\"LINQ Aggregate\"\n\t\t\t\tclass=\"wth-btn-rounded wth-no-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> No <\/span>\n\t\t\t<\/button>\n\t\t<\/div>\n\t<\/header>\n\n\t<div class=\"wth-form hidden\">\n\t\t<div class=\"wth-form-wrapper\">\n\t\t\t<div class=\"wth-title\"><\/div>\n\t\t\t\n\t\t\t<textarea class=\"wth-message\"><\/textarea>\n\n\t\t\t<button class=\"btn btn-primary wth-btn-submit\">Send<\/button>\n\t\t\t<button class=\"btn wth-btn-cancel\">Cancel<\/button>\n\t\t\n\t\t<\/div>\n\t<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Summary: in this tutorial, you&#8217;ll learn how to use the LINQ Aggregate() method to perform a cumulative operation on a sequence. Introduction to the LINQ Aggregate() method The Aggregate() method performs an operation on each element of a sequence, taking into account the result of the previous operation. The Aggregate() method starts by performing an [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":919,"menu_order":39,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1039","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.csharptutorial.net\/wp-json\/wp\/v2\/pages\/1039","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.csharptutorial.net\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.csharptutorial.net\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.csharptutorial.net\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.csharptutorial.net\/wp-json\/wp\/v2\/comments?post=1039"}],"version-history":[{"count":5,"href":"https:\/\/www.csharptutorial.net\/wp-json\/wp\/v2\/pages\/1039\/revisions"}],"predecessor-version":[{"id":2417,"href":"https:\/\/www.csharptutorial.net\/wp-json\/wp\/v2\/pages\/1039\/revisions\/2417"}],"up":[{"embeddable":true,"href":"https:\/\/www.csharptutorial.net\/wp-json\/wp\/v2\/pages\/919"}],"wp:attachment":[{"href":"https:\/\/www.csharptutorial.net\/wp-json\/wp\/v2\/media?parent=1039"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}