C# Guid CompareTo(Object)

Description

Guid CompareTo(Object) compares this instance to a specified object and returns an indication of their relative values.

Syntax

Guid.CompareTo(Object) has the following syntax.


public int CompareTo(
  Object value
)

Parameters

Guid.CompareTo(Object) has the following parameters.

  • value - An object to compare, or null.

Returns

Guid.CompareTo(Object) method returns A signed number indicating the relative values of this instance and value. Return value Description A negative integer This instance is less than value. Zero This instance is equal to value. A positive integer This instance is greater than value, or value is null.

Example

The following example demonstrates CompareTo method.


//from w  ww . j a  v a2s  .  c o m

using System;

class Sample 
{
    public static void Main() 
    {
        Guid guidX = new Guid("{CA761232-ED42-11CE-BACD-00AA0057B223}");
        Console.WriteLine(guidX.CompareTo((Object)new Guid("{CA761232-ED42-11CE-BACD-00AA0057B224}")));
    }
}

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