The MathF.Max() method in C# returns the larger of the two specified numbers.
Syntax
Following is the syntax −
public static float Max (float val1, float val2);
Above, val1 is the first number, whereas val2 is the second number. Both of these numbers are compared.
Example
Let us now see an example to implement the MathF.Max() method −
using System;
public class Demo {
public static void Main(){
float val1 = 11.89f;
float val2 = 55.67f;
Console.WriteLine("Maximum Value = "+MathF.Max(val1, val2));
}
}Output
This will produce the following output −
Maximum Value = 55.67
Example
Let us now see another example to implement the MathF.Max() method −
using System;
public class Demo {
public static void Main(){
float val1 = 1.00f;
float val2 = 0.11f;
Console.WriteLine("Maximum Value = "+MathF.Max(val1, val2));
}
}Output
This will produce the following output −
Maximum Value = 1