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; Static;
CF2.  Function ToBoolean ( Value : Cardinal ) : Boolean; Static;
CF3.  Function ToBoolean ( Value : Byte ) : Boolean; Static;
CF4.  Function ToBoolean ( Value : Char ) : Boolean; Static;
CF5.  Function ToBoolean ( Value : SmallInt ) : Boolean; Static;
CF6.  Function ToBoolean ( Value : ShortInt ) : Boolean; Static;
CF7.  Function ToBoolean ( Value : Integer ) : Boolean; Static;
CF8.  Function ToBoolean ( Value : Int64 ) : Boolean; Static;
CF9.  Function ToBoolean ( Value : UInt64 ) : Boolean; Static;
CF10.  Function ToBoolean ( Value : Word ) : Boolean; Static;
CF11.  Function ToBoolean ( Value : Single ) : Boolean; Static;
CF12.  Function ToBoolean ( Value : Double ) : Boolean; Static;
CF13.  Function ToBoolean ( Value : Decimal ) : Boolean; Static;
CF14.  Function ToBoolean ( Value : String ) : Boolean; Static;
CF15.  Function ToBoolean ( Value : String; FormatProvider : IFormatProvider ) : Boolean; Static;
CF16.  Function ToBoolean ( Value : Object ) : Boolean; Static;
CF17.  Function ToBoolean ( Value : 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
 Author links

 Buy Website Traffic at
 Buywebsitetrafficexperts.com

 Buy Proxies at
 Buyproxies.io
 
 
 
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.
   True
 
 
Delphi Programming Neil Moffatt 2002 - 2017. All rights reserved.  |  Contact the author