Home  |  Delphi .net Home  |  System.Char  |  CompareTo Method
  
CompareTo  
Method  
Compares the current Char value to another
Char Structure
System NameSpace
CF1.  Function CompareTo ( Target : Object ) : Integer;
CF : Methods with this mark are Compact Framework Compatible
Description
Compares the current (source) value with the Target value. The Target parameter must be a Char object or a null reference.
 
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.Char
 Author links

 Buy Website Traffic at
 Buywebsitetrafficexperts.com

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

var
  valueA, valueB : Char;
  result         : Integer;

begin
  valueA := 'A';
  valueB := 'Z';

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

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

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

  Console.ReadLine;
end.
   valueA compared to valueB = -25
   valueB compared to valueB = 0
   valueB compared to valueA = 25
 
 
Delphi Programming Neil Moffatt 2002 - 2017. All rights reserved.  |  Contact the author