Export (0) Print
Expand All

Version.CompareTo Method

Compares this instance to a specified object and returns an indication of their relative values.

[Visual Basic]
Public Overridable Function CompareTo( _
   ByVal version As Object _
) As Integer Implements IComparable.CompareTo
[C#]
public virtual int CompareTo(
 object version
);
[C++]
public: virtual int CompareTo(
 Object* version
);
[JScript]
public function CompareTo(
   version : Object
) : int;

Parameters

version
An object to compare, or a null reference (Nothing in Visual Basic).

Return Value

Return Value Description
Less than zero This instance is before version.
Zero This instance is the same as version.
Greater than zero This instance is subsequent to version.

-or-

version is a null reference (Nothing in Visual Basic).

Implements

IComparable.CompareTo

Exceptions

Exception Type Condition
ArgumentException version is not of type Version and is not a null reference (Nothing in Visual Basic).

Remarks

The components of Version in decreasing order of importance are: major, minor, build, and revision. An unknown component is assumed to be older than any known component.

For example:

  • version 1.1 is older than version 1.1.0
  • version 1.1 is older than version 1.1.1
  • version 1.1 is older than version 1.1.2.3
  • version 1.1.2 is older than version 1.1.2.4
  • version 1.2.5 is newer than version 1.2.3.4

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

See Also

Version Class | Version Members | System Namespace | Equals

Show:
© 2015 Microsoft