C# Enumerable Average(IEnumerable>)
Description
Computes the average of a sequence of nullable Double values.
Syntax
Enumerable.Average(IEnumerable)
has the following syntax.
public static Nullable<double> Average(
this IEnumerable<Nullable<double>> source
)
Parameters
source
- A sequence of nullable Double values to calculate the average of.
Example
The following code example demonstrates how to use Average(IEnumerable) to calculate an average.
// w ww . j a va 2s .c o m
using System;
using System.Linq;
using System.Collections.Generic;
public class MainClass{
public static void Main(String[] argv){
long?[] longs = { null, 10007L, 123123L, 123123123123L };
double? average = longs.Average();
Console.WriteLine("The average is {0}.", average);
}
}
The code above generates the following result.