C# Math Min(Decimal, Decimal)

Description

Math Min(Decimal, Decimal) returns the smaller of two decimal numbers.

Syntax

Math.Min(Decimal, Decimal) has the following syntax.


public static decimal Min(
  decimal val1,
  decimal val2
)

Parameters

Math.Min(Decimal, Decimal) has the following parameters.

  • val1 - The first of two decimal numbers to compare.
  • val2 - The second of two decimal numbers to compare.

Returns

Math.Min(Decimal, Decimal) method returns Parameter val1 or val2, whichever is smaller.

Example

The following example demonstrates how to use the Min method to return and display the smaller of two variables.


using System;//from  ww  w.ja va 2s . c  om

class Sample 
{
    public static void Main() 
    {
        Decimal  xDecimal1 = 7m,   xDecimal2 = 57m;
        Console.WriteLine(Math.Min(xDecimal1, xDecimal2));
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version