Export (0) Print
Expand All

Boolean.Parse Method

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

Namespace: System
Assembly: mscorlib (in mscorlib.dll)

public static bool Parse (
	string value
)
public static boolean Parse (
	String value
)
public static function Parse (
	value : String
) : boolean

Parameters

value

A string containing the value to convert.

Return Value

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

Exception typeCondition

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 example illustrates the use of Parse method.

bool val;
string input;

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

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

var val : Boolean;
var input : String;

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

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft