C# Decimal GreaterThan
Description
Decimal GreaterThan
returns a value indicating whether
a specified Decimal is greater than another specified Decimal.
Syntax
Decimal.GreaterThan
has the following syntax.
public static bool operator >(
decimal d1,
decimal d2
)
Parameters
Decimal.GreaterThan
has the following parameters.
d1
- The first value to compare.d2
- The second value to compare.
Returns
Decimal.GreaterThan
method returns true if d1 is greater than d2; otherwise, false.
Example
The GreaterThan method defines the operation of the greater than operator for Decimal values. It enables code such as the following:
using System;// ww w .ja v a 2 s. co m
public class Example
{
public static void Main()
{
Decimal number1 = 16354.0699m;
Decimal number2 = 16354.0695m;
Console.WriteLine("{0} > {1}: {2}", number1,
number2, number1 > number2);
number1 = Decimal.Round(number1, 2);
number2 = Decimal.Round(number2, 2);
Console.WriteLine("{0} > {1}: {2}", number1,
number2, number1 > number2);
}
}
The code above generates the following result.