C# Enumerable Max(IEnumerable>)
Description
Returns the maximum value in a sequence of nullable Int32 values.
Syntax
public static Nullable<int> Max(
this IEnumerable<Nullable<int>> source
)
Parameters
source
- A sequence of nullable Int32 values to determine the maximum value of.
Returns
Returns the maximum value in a sequence of nullable Int32 values.
Example
The following code example demonstrates how to use Max(IEnumerable) to determine the maximum value in a sequence.
/*from ww w.j a v a 2 s . c om*/
using System;
using System.Linq;
using System.Collections.Generic;
public class MainClass{
public static void Main(String[] argv){
double?[] doubles = { null, 1.5E+104, 9E+103, -2E+103 };
double? max = doubles.Max();
Console.WriteLine("The largest number is {0}.", max);
}
}
The code above generates the following result.