C# Decimal Compare
Description
Decimal Compare
compares two specified Decimal values.
Syntax
Decimal.Compare
has the following syntax.
public static int Compare(
decimal d1,
decimal d2
)
Parameters
Decimal.Compare
has the following parameters.
d1
- The first value to compare.d2
- The second value to compare.
Returns
Decimal.Compare
method returns A signed number indicating the relative values of d1 and d2. Return value
Meaning Less than zero d1 is less than d2. Zero d1 and d2 are equal. Greater
than zero d1 is greater than d2.
Example
The following code example compares several Decimal values to a reference Decimal value using the Compare method.
using System;/* w w w. j ava 2s . c o m*/
class DecCompareEqualsDemo
{
public static void Main( )
{
decimal Left = new decimal( 123.456 );
Console.WriteLine(Decimal.Compare( Left, new decimal( 1.2345600E+2 ) ) );
}
}
The code above generates the following result.