C# Enumerable Min(IEnumerable>)

Description

Returns the minimum value in a sequence of nullable Int32 values.

Syntax


public static Nullable<int> Min(
  this IEnumerable<Nullable<int>> source
)

Parameters

  • source - A sequence of nullable Int32 values to determine the minimum value of.

Example

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


/*w  w w  .  j a v  a2 s  .c o m*/
using System;
using System.Linq;
using System.Collections.Generic;
public class MainClass{
  public static void Main(String[] argv){  
      int?[] grades = { 78, 92, null, 99, 37, 81 };

      int? min = grades.Min();

      Console.WriteLine("The lowest grade is {0}.", min);
  }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Linq »




Enumerable