C# Int32 CompareTo(Object)
Description
Int32 CompareTo(Object)
compares this instance to a
specified object and returns an indication of their relative values.
Syntax
Int32.CompareTo(Object)
has the following syntax.
public int CompareTo(
Object value
)
Parameters
Int32.CompareTo(Object)
has the following parameters.
value
- An object to compare, or null.
Returns
Int32.CompareTo(Object)
method returns A signed number indicating the relative values of this instance and value.
Return Value Description 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 example demonstrates the Int32.CompareTo(Object) method.
using System;/*from www. jav a 2 s. com*/
public class ValueComparison
{
public static void Main()
{
int mainValue = 16325;
int zeroValue = 0;
Console.WriteLine(mainValue.CompareTo((Object)zeroValue));
}
}
The code above generates the following result.