C# Enumerable Max(IEnumerable>)

Description

Returns the maximum value in a sequence of nullable Single values.

Syntax


public static Nullable<float> Max(
  this IEnumerable<Nullable<float>> source
)

Parameters

  • source - A sequence of nullable Single values to determine the maximum value of.

Returns

Returns the maximum value in a sequence of nullable Single values.

Example

The following code example demonstrates how to use Max(IEnumerable) to determine the maximum value in a sequence.


//from www.  j  a  va  2 s.  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.





















Home »
  C# Tutorial »
    System.Linq »




Enumerable