Linq Example 41 - Average Projection

11:27 PM
Linq Query:

//Average Projection

            string[] words = { "GodOfWar", "CallOfDuty", "AssasinCreed" };

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

            Console.WriteLine("Average word Length is {0} characters long.", avgWordLeng);

//

Output:
Average word Length is 10 characters long.

0 comments:

Post a Comment