C# Enumerable Min(IEnumerable)

Description

Returns the minimum value in a sequence of Decimal values.

Syntax


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

Parameters

  • source - A sequence of Decimal 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.


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