Average values from Enumerable.Range in CSharp
Description
The following code shows how to average values from Enumerable.Range.
Example
using System;/*from www. j a v a 2s. co m*/
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);
}
}
The code above generates the following result.