C# Enumerable Average(IEnumerable>)
Description
Computes the average of a sequence of nullable Decimal values.
Syntax
public static Nullable<decimal> Average(
this IEnumerable<Nullable<decimal>> source
)
Parameters
source
- A sequence of nullable Decimal values to calculate the average of.
Example
The following code example demonstrates how to use Average(IEnumerable) to calculate an average.
/* ww w .jav a 2 s . 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.