Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

c#
math
max
communitycreator

What is Math.Max() in C#?

Arslan Bajwa

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

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);
    

RELATED TAGS

c#
math
max
communitycreator

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring