Use Aggregate with for string length in CSharp

Description

The following code shows how to use Aggregate with for string length.

Example


   /*w ww.j  av  a 2  s  .  com*/


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

    class Program
    {
        static void Main(string[] args)
        {
            string[] curries = { "abc", "ab", "abcd" };

            Console.WriteLine(curries.Aggregate<string, string, int>(
                "Some curries:",
                (a, b) => a + " " + b,
                a => a.Length));
        }
    }

The code above generates the following result.





















Home »
  C# Tutorial »
    LINQ »




Operator
Select
Where
OrderBy
Group
Join
Let
LINQ