Sum with Projection : Sum : LINQ C# Source Code


Custom Search

C# Source Code » LINQ » Sum »

 

Sum with Projection








    
 
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);
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo LINQ
» Sum