C# Version CompareTo(Version)

Description

Version CompareTo(Version) compares the current Version object to a specified Version object and returns an indication of their relative values.

Syntax

Version.CompareTo(Version) has the following syntax.


public int CompareTo(
  Version value
)

Parameters

Version.CompareTo(Version) has the following parameters.

  • value - A Version object to compare to the current Version object, or null.

Returns

Version.CompareTo(Version) method returns A signed integer that indicates the relative values of the two objects, as shown in the following table. Return value Meaning Less than zero The current Version object is a version before value. Zero The current Version object is the same version as value. Greater than zero The current Version object is a version subsequent to value. -or- value is null.

Example


/*  ww w.  j av  a  2s. c  om*/
using System;

class Sample 
{
    public static void Main() 
    {
        Version interim = new Version(1,2,3,4);
        Version interim1 = new Version(1,2,4,4);
    
        Console.WriteLine(interim.CompareTo(interim1));
    }
}

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