This documentation is archived and is not being maintained.

Boolean.Parse Method

Converts the specified string representation of a logical value to its Boolean equivalent.

[Visual Basic]
Public Shared Function Parse( _
   ByVal value As String _
) As Boolean
public static bool Parse(
 string value
public: static bool Parse(
 String* value
public static function Parse(
   value : String
) : Boolean;


A string containing the value to convert.

Return Value

true if value is equivalent to TrueString; otherwise, false.


Exception Type Condition
ArgumentNullException value is a null reference (Nothing in Visual Basic).
FormatException value is not equivalent to TrueString or FalseString.


The value parameter, optionally preceded or trailed by white space, must contain either TrueString or FalseString; otherwise, an exception is thrown. The comparison is case-insensitive.


The following code sample illustrates the use of Parse in the context of Boolean:

[Visual Basic] 
Dim val As Boolean
Dim input As String

input = Boolean.TrueString
val = Boolean.Parse(input)
Console.WriteLine("{0} parsed as {1}", input, val)

bool val;
string input;

input = bool.TrueString;
val = bool.Parse(input);
Console.WriteLine("{0} parsed as {1}", input, val);

Boolean val;
String* input;

input = Boolean::TrueString;
val = Boolean::Parse(input);
Console::WriteLine("{0} parsed as {1}", input, __box(val));

var val : Boolean;
var input : String;

input = Boolean.TrueString;
val = Boolean.Parse(input);
Console.WriteLine("{0} parsed as {1}", input, val);


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

See Also

Boolean Structure | Boolean Members | System Namespace | ArgumentNullException | FormatException | String | TrueString | FalseString