ToBoolean Method (String, IFormatProvider)

Convert.ToBoolean Method (String, IFormatProvider)

 

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

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

public static bool ToBoolean(
	string value,
	IFormatProvider provider
)

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.Boolean

true 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
Return to top
Show:
© 2016 Microsoft