C# Enumerable Min(IEnumerable)

Description

Returns the minimum value in a sequence of Int32 values.

Syntax


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

Parameters

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

Returns

returns The minimum value in the sequence.

Example

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


//w w w  .  ja v a 2s.c o m
using System;
using System.Linq;
using System.Collections.Generic;
public class MainClass{
  public static void Main(String[] argv){  

    double[] doubles = { 1.5E+104, 9E+103, -2E+103 };

    double min = doubles.Min();

    Console.WriteLine("The smallest number is {0}.", min);
  }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Linq »




Enumerable