Average with int array : Average « LINQ « C# / C Sharp






Average with int array

 


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

 








Related examples in the same category

1.uses Average to get the average of all values of an integer array.
2.uses Average to get the average length of the words in the string array.
3.Grouped Average
4.Use Average method to calculate the average value from a query