C# Decimal CompareTo(Object)
Description
Decimal CompareTo(Object)
compares this instance to
a specified object and returns a comparison of their relative values.
Syntax
Decimal.CompareTo(Object)
has the following syntax.
public int CompareTo(
Object value
)
Parameters
Decimal.CompareTo(Object)
has the following parameters.
value
- The object to compare with this instance, or null.
Returns
Decimal.CompareTo(Object)
method returns A signed number indicating the relative values of this instance and value.
Return value Meaning Less than zero This instance is less than value. Zero
This instance is equal to value. Greater than zero This instance is greater
than value. -or- value is null.
Example
The following code example demonstrates generic versions of the CompareTo method.
/*from w ww . j a v a2s. c o m*/
using System;
class Sample
{
public static void Main()
{
Decimal f1 = -5.5m, f2 = 5.5m;
Console.WriteLine(f1.CompareTo((object)f2));
}
}
The code above generates the following result.