C# Math Max(Decimal, Decimal)
Description
Math Max(Decimal, Decimal)
returns the larger of two
decimal numbers.
Syntax
Math.Max(Decimal, Decimal)
has the following syntax.
public static decimal Max(
decimal val1,
decimal val2
)
Parameters
Math.Max(Decimal, Decimal)
has the following parameters.
val1
- The first of two decimal numbers to compare.val2
- The second of two decimal numbers to compare.
Returns
Math.Max(Decimal, Decimal)
method returns Parameter val1 or val2, whichever is larger.
Example
The following example demonstrates how to use the Max method to return and display the greater of two variables.
using System;//from w ww .j a v a2s. c o m
class Sample
{
public static void Main()
{
Decimal xDecimal1 = 7m, xDecimal2 = 57m;
Console.WriteLine(Math.Max(xDecimal1, xDecimal2));
}
}
The code above generates the following result.