C# Enumerable Max(IEnumerable)

Description

Returns the maximum value in a sequence of Single values.

Syntax


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

Parameters

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

Returns

returns The maximum value in the sequence.

Example

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


/*from  ww  w. j  ava 2 s . co  m*/
using System;
using System.Linq;
using System.Collections.Generic;
public class MainClass{
  public static void Main(String[] argv){  
     List<long> longs = new List<long> { 421231236L, 4612335L, 12325L };

     long max = longs.Max();

     Console.WriteLine("The largest number is {0}.", max);

  }
}
    

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Linq »




Enumerable