在C#中, Max(Single,Single)是MathF类方法,用于返回两个指定数字中较大的数字。
Syntax: public static float Max (float x, float y);
Here, x and y are the two floating point numbers which are compared.
Return Type: This method returns the maximum of the two numbers which specified into the parameter list and return type depends on the type of arguments passed.
例子:
// C# program to demonstrate the
// MathF.Max(Single, Single) method
using System;
class GFG {
// Main Method
static void Main()
{
// taking different float values
float f1 = 34.56f, f2 = 37.3412f;
float f3 = -675.2f, f4 = -56.47f;
// displaying result
Console.WriteLine(MathF.Max(f1, f2));
Console.WriteLine(MathF.Max(f3, f4));
}
}
输出:
37.3412
-56.47