C# Int64 CompareTo(Int64)

Description

Int64 CompareTo(Int64) compares this instance to a specified 64-bit signed integer and returns an indication of their relative values.

Syntax

Int64.CompareTo(Int64) has the following syntax.


public int CompareTo(
  long value
)

Parameters

Int64.CompareTo(Int64) has the following parameters.

  • value - An integer to compare.

Returns

Int64.CompareTo(Int64) 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.

Example

The following code example demonstrates the CompareTo method.


using System;//w ww.  jav a2s . c o m

class Sample 
{
    public static void Main() 
    {
        Int64    e1 = 4,     e2 = -4;
        Console.WriteLine(e1.CompareTo(e2));
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version