C# Enumerable Sum(IEnumerable>)
Description
Computes the sum of a sequence of nullable Double values.
Syntax
public static Nullable<double> Sum(
this IEnumerable<Nullable<double>> source
)
Parameters
source
- A sequence of nullable Double values to calculate the sum of.
Example
The following code example demonstrates how to use Sum(IEnumerable) to sum the values of a sequence.
// w w w . j a v a 2 s .co m
using System;
using System.Linq;
using System.Collections.Generic;
public class MainClass{
public static void Main(String[] argv){
float?[] points = { null, 0, 9.83F, null, 1.0F, 3.46F, 8.1F };
float? sum = points.Sum();
Console.WriteLine("Total points earned: {0}", sum);
}
}
The code above generates the following result.