Home  |  Delphi .net Home  |  System.Boolean  |  CompareTo Method
  
CompareTo  
Method  
Compares the current Boolean value to another
Boolean Structure
System NameSpace
CF1.  Function CompareTo ( Target : Object ) : Integer;
CF : Methods with this mark are Compact Framework Compatible
Description
Returns one of the following values :
 
Source is false and Target is false Gives <0
Source is false and Target is true Gives -1
Source is true and Target is false Gives 1
Source is true and Target is true Gives 0

 
Where the Source is the current Boolean.
 
The exact return value is not guaranteed.
 
Microsoft MSDN Links
System
System.Boolean
 Author links

 Buy Website Traffic at
 Buywebsitetrafficexperts.com

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

var
  aFalse, aTrue : Boolean;
  result        : Integer;

begin
  aFalse := false;
  aTrue  := true;

  result := aFalse.CompareTo(TObject(aFalse));
  Console.WriteLine('aFalse compared to aFalse = {0}', result.ToString);

  result := aFalse.CompareTo(TObject(aTrue));
  Console.WriteLine('aFalse compared to aTrue  = {0}', result.ToString);

  result := aTrue.CompareTo(TObject(aFalse));
  Console.WriteLine('aTrue  compared to aFalse = {0}', result.ToString);

  result := aTrue.CompareTo(TObject(aTrue));
  Console.WriteLine('aTrue  compared to aTrue  = {0}', result.ToString);

  Console.ReadLine;
end.
   aFalse compared to aFalse = 0
   aFalse compared to aTrue  = -1
   aTrue  compared to aFalse = 1
   aTrue  compared to aTrue  = 0
 
 
Delphi Programming Neil Moffatt 2002 - 2017. All rights reserved.  |  Contact the author