Sum with Projection

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

public class MainClass {
    public static void Main() {
        string[] words = { "cherry", "apple", "blueberry" };

        double totalChars = words.Sum(w => w.Length);

        Console.WriteLine("There are a total of {0} characters in these words.", totalChars);
    }
}

    


This entry was posted in LINQ. Bookmark the permalink.