uses Average to get the average length of the words in the string array. : Average : LINQ C# Source Code


Custom Search

C# Source Code » LINQ » Average »

 

uses Average to get the average length of the words in the string array.








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

public class MainClass {
    public static void Main() {
        string[] words = { "ch", "a", "blue" };

        double averageLength = words.Average(w => w.Length);

        Console.WriteLine("The average word length is {0} characters.", averageLength);
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo LINQ
» Average