C# Math Min(Int32, Int32)

Description

Math Min(Int32, Int32) returns the smaller of two 32-bit signed integers.

Syntax

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


public static int Min(
  int val1,
  int val2
)

Parameters

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

  • val1 - The first of two 32-bit signed integers to compare.
  • val2 - The second of two 32-bit signed integers to compare.

Returns

Math.Min(Int32, Int32) 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;// ww w.j  a va 2s.  c o m

class Sample 
{
    public static void Main() 
    {
        int      xInt1     = -3,   xInt2     = 53;
        Console.WriteLine(Math.Min(xInt1, xInt2));
    }
}

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