Home  |  Delphi .net Home  |  System.Version  |  CompareTo Method
  
CompareTo  
Method  
Compares the current Version value to another
Version Class
System NameSpace
CF1.  Function CompareTo ( Target : Object ) : Integer;
CF : Methods with this mark are Compact Framework Compatible
Description
Compares the current (source) version value with the Target version value. The Target parameter must be a Version object or a null reference. Quite why this parameter is not Version is not clear.
 
Returns one of the following values :
 
Source < Target Gives <0
Source = Target Gives  0
Source > Target Gives >0

 
The exact value is not guaranteed.
Microsoft MSDN Links
System
System.Version
 Author links

 Buy Website Traffic at
 Buywebsitetrafficexperts.com

 Buy Proxies at
 Buyproxies.io
 
 
 
A simple example
program Project1;
{$APPTYPE CONSOLE}

var
  ver1, ver2 : Version;
  result     : Integer;

begin
  // Fabricate a version number
  ver1 := Version.Create('1.2.3.4');

  // Get the current Operating System version
  ver2 := Environment.OSVersion.Version;

  Console.WriteLine('ver1 = ' + ver1.ToString);
  Console.WriteLine('ver2 = ' + ver2.ToString);

  // Compare ver1 to ver2
  result := ver1.CompareTo(ver2);
  Console.WriteLine('ver1 compared to ver2 = {0}', result.ToString);

  Console.ReadLine;
end.
   ver1 = 1.2.3.4
   ver2 = 5.1.2600.0
   ver1 compared to ver2 = -1
 
 
Delphi Programming Neil Moffatt 2002 - 2017. All rights reserved.  |  Contact the author