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

    



This entry was posted in LINQ. Bookmark the permalink.