What is Math.Max() in C#?

C# has a built-in Math class which provides useful mathematical functions and operations. The class has the Max() function, which is used to compute the larger of two specified numbers.

Syntax

Max (type param1, type param2);

Variants

  • Max(Single, Single)

    This type returns the larger number from two single-precision floating-point numbers.

    public static float Max (float param1, float param2);
    
  • Max(Double, Double)

    This type returns the larger number from two double-precision floating-point numbers.

    public static double Max (double param1, double param2);
    
  • Max(Decimal, Decimal)

    This type returns the larger number from two decimal numbers.

    public static decimal Max (decimal param1, decimal param2);
    
  • Max(Byte, Byte)

    This type returns the larger number from two 8-bit unsigned integers.

    public static byte Max (byte param1, byte param2);
    
  • Max(UInt16, UInt16)

    This type returns the larger number from two 16-bit unsigned integers.

    public static ushort Max (ushort param1, ushort param2);
    
  • Max(UInt32, UInt32)

    This type returns the larger number from two 32-bit unsigned integers.

    public static uint Max (uint param1, uint param2);
    
  • Max(UInt64, UInt64)

    This type returns the larger number from two 64-bit unsigned integers.

    public static ulong Max (ulong param1, ulong param2);
    
  • Max(SByte, SByte)

    This type returns the larger number from two 8-bit signed integers.

    public static sbyte Max (sbyte param1, sbyte param2);
    
  • Max(Int16, Int16)

    This type returns the larger number from two 16-bit signed integers.

    public static short Max (short param1, short param2);
    
  • Max(Int32, Int32)

    This type returns the larger number from two 32-bit signed integers.

    public static int Max (int param1, int param2);
    
  • Max(Int64, Int64)

    This type returns the larger number from two 64-bit signed integers.

    public static long Max (long param1, long param2);
    

Free Resources