Home  |  Delphi .net Home  |  System.Convert  |  ToBoolean Method
ToBoolean  
Method  
Converts data from one data type to a Boolean data type
Convert Class
System NameSpace
CF1.  Function ToBoolean ( Value : Boolean; ) : Boolean;
CF2.  Function ToBoolean ( Value : Cardinal; ) : Boolean;
CF3.  Function ToBoolean ( Value : Byte; ) : Boolean;
CF4.  Function ToBoolean ( Value : Char; ) : Boolean;
CF5.  Function ToBoolean ( Value : SmallInt; ) : Boolean;
CF6.  Function ToBoolean ( Value : ShortInt; ) : Boolean;
CF7.  Function ToBoolean ( Value : Integer; ) : Boolean;
CF8.  Function ToBoolean ( Value : Int64; ) : Boolean;
CF9.  Function ToBoolean ( Value : UInt64; ) : Boolean;
CF10.  Function ToBoolean ( Value : Word; ) : Boolean;
CF11.  Function ToBoolean ( Value : Single; ) : Boolean;
CF12.  Function ToBoolean ( Value : Double; ) : Boolean;
CF13.  Function ToBoolean ( Value : Decimal; ) : Boolean;
CF14.  Function ToBoolean ( Value : String; ) : Boolean;
CF15.  Function ToBoolean ( Value:StringValue : String; FormatProvider : IFormatProvider; ) : Boolean;
CF16.  Function ToBoolean ( Value : Object; ) : Boolean;
CF17.  Function ToBoolean ( Value:ObjectValue : Object; FormatProvider : IFormatProvider; ) : Boolean; Static;
CF : Methods with this mark are Compact Framework Compatible
Description
Attempts to transfer the value from one of the given Value data types to Boolean.
 
The optional FormatProvider parameter determines the parsing rules and is beyond the scope of this article.
Notes
An exception is thrown if the conversion fails.
Microsoft MSDN Links
System
System.Convert
 
 
A simple example
program Project1;
{$APPTYPE CONSOLE}

var
  myBool : Boolean;
  myStr  : String;

begin
  myStr  := 'true';

  myBool := System.Convert.ToBoolean(myStr);

  Console.WriteLine(myBool.ToString);

  Console.ReadLine;
end.
Show full unit code
  True
 
 
Delphi Programming © Neil Moffatt All rights reserved.  |  Contact the author