-
Notifications
You must be signed in to change notification settings - Fork 26
Average
Eugene Sadovoi edited this page Jul 15, 2016
·
4 revisions
Computes the average of a sequence of values that are obtained by invoking an optional transform function on each element of the input sequence.
Average([selector])
A transform function to apply to each element. TElement selector(TSource)
The average of the sequence of values
If no selector
function is specified the implementation assumes sequence of number
values.
The following code example demonstrates how to use Average
to calculate an average.
var fruits = [ "apple", "banana", "mango", "orange", "passionfruit", "grape" ];
var average = Enumerable.asEnumerable(fruits).Average(s => s.Length);
console.log("The average string length is " + average);
// This code produces the following output:
// The average string length is 6.5.