C# Enumerable Max(IEnumerable>)

Description

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

Syntax


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

Parameters

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

Example

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


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