System.Convert.ToBoolean Method

Converts the specified string representation of a logical value to its Boolean equivalent, using the specified culture-specific formatting information.

Syntax

public static bool ToBoolean (string value, IFormatProvider provider)

Parameters

value
A string that contains the value of either bool.TrueString or bool.FalseString.
provider
An object that supplies culture-specific formatting information. This parameter is ignored.

Returns

true if value equals bool.TrueString, or false if value equals bool.FalseString or null.

Remarks

If you prefer not to handle an exception if the conversion fails, you can call the bool.TryParse(string, Boolean@) method instead. It returns a bool value that indicates whether the conversion succeeded or failed.

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0