Convert.ToBoolean Method (String, IFormatProvider)
.NET Framework (current version)
Converts the specified string representation of a logical value to its Boolean equivalent, using the specified culture-specific formatting information.
Assembly: mscorlib (in mscorlib.dll)
Parameters
- value
-
Type:
System.String
A string that contains the value of either Boolean.TrueString or Boolean.FalseString.
- provider
-
Type:
System.IFormatProvider
An object that supplies culture-specific formatting information. This parameter is ignored.
Return Value
Type: System.Booleantrue if value equals Boolean.TrueString, or false if value equals Boolean.FalseString or null.
| Exception | Condition |
|---|---|
| FormatException | value is not equal to TrueString or FalseString. |
If you prefer not to handle an exception if the conversion fails, you can call the Boolean.TryParse method instead. It returns a Boolean value that indicates whether the conversion succeeded or failed.
Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Show: