C# Enumerable Average(IEnumerable>)
Description
Computes the average of a sequence of nullable Int64 values.
Syntax
public static Nullable<double> Average(
this IEnumerable<Nullable<long>> source
)
Parameters
source
- A sequence of nullable Int64 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 v a2s. c om*/
using System;
using System.Linq;
using System.Collections.Generic;
public class MainClass{
public static void Main(String[] argv){
long?[] longs = { null, 10007L, 37L, 12123123123123L };
double? average = longs.Average();
Console.WriteLine("The average is {0}.", average);
}
}
The code above generates the following result.