Average with int array : Average « LINQ « C# / CSharp Tutorial






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

public class MainClass {
    public static void Main() {
        IEnumerable<int> intSequence = Enumerable.Range(1, 10);
        foreach (int i in intSequence)
            Console.WriteLine(i);
        double average = intSequence.Average();
        Console.WriteLine("Here is the average:  {0}", average);
    }
}








22.19.Average
22.19.1.Using Average to get the average of all values of an integer array.
22.19.2.Average with int array
22.19.3.Using Average to get the average length of the words in the string array.
22.19.4.Grouped Average
22.19.5.Using Average method to calculate the average value from a query
22.19.6.Numeric Aggregates: Average