LINQ-use Average to get the average of all numbers in an array.

This is the function to get Average of all numbers in Array using LINQ.

public void FindAvgNumber()
{

int[] numbers = { 10,4,5,7,9,23,45 }; double averageNum = numbers.Average(); Console.WriteLine("The average number is {0}.", averageNum);
}

We can also use Average
to get the average length of all word in array

public void FindAvgWordLength() { string[] words = { "India", "America", "England","Iraq" }; double averageLength = words.Average(w => w.Length); Console.WriteLine("The average word length is {0} characters.", averageLength); }