C# Enumerable Max(IEnumerable>)
Description
Returns the maximum value in a sequence of nullable Int64 values.
Syntax
public static Nullable<long> Max(
this IEnumerable<Nullable<long>> source
)
Parameters
source
- A sequence of nullable Int64 values to determine the maximum value of.
Returns
Returns the maximum value in a sequence of nullable Int64 values.
Example
The following code example demonstrates how to use Max(IEnumerable) to determine the maximum value in a sequence.
/*from ww w. j av a2s . c o m*/
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.