Home  |  Delphi .net Home  |  System.Boolean  |  Parse Method
Parse  
Method  
Converts a string representation of a Boolean into a Boolean value
Boolean Structure
System NameSpace
CF1.  Function Parse ( Value : String; ) : Boolean; Static;
CF : Methods with this mark are Compact Framework Compatible
Description
Attempts to parse the Value string into a true or false value, returning a Boolean object with the appropriate value.
Notes
Warning : An exception is thrown if the parse encounters unexpected characters.
Microsoft MSDN Links
System
System.Boolean
 
 
A simple example
program Project1;
{$APPTYPE CONSOLE}

var
  boolStr : String;

begin
  boolStr := 'true';
  if System.Boolean.Parse(boolStr)
  then Console.WriteLine('''' + boolStr + '''    parses to true')
  else Console.WriteLine('''' + boolStr + '''   parses to false');

  boolStr := ' True ';
  if System.Boolean.Parse(boolStr)
  then Console.WriteLine('''' + boolStr + '''  parses to true')
  else Console.WriteLine('''' + boolStr + '''  parses to false');

  boolStr := ' FALSE ';
  if System.Boolean.Parse(boolStr)
  then Console.WriteLine('''' + boolStr + ''' parses to true')
  else Console.WriteLine('''' + boolStr + ''' parses to false');

  Console.ReadLine;
end.
Show full unit code
  'true'    parses to true
  ' True '  parses to true
  ' FALSE ' parses to false
 
 
Delphi Programming © Neil Moffatt All rights reserved.  |  Contact the author