Convert.ToString Method (Boolean)
Microsoft Silverlight will reach end of support after October 2021. Learn more.
Converts the value of the specified Boolean to its equivalent String representation.
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Syntax
'Declaration
Public Shared Function ToString ( _
value As Boolean _
) As String
public static string ToString(
bool value
)
Parameters
- value
Type: System.Boolean
A Boolean value.
Return Value
Type: System.String
The String equivalent of the value of value.
Remarks
This implementation is identical to Boolean.ToString. It returns Boolean.TrueString for true values and Boolean.FalseString for false values.
Examples
The following example illustrates the conversion of a Boolean to a String, using ToString. It also illustrates that the string returned by the conversion equals either Boolean.TrueString or Boolean.FalseString.
Dim falseFlag As Boolean = False
Dim trueFlag As Boolean = True
outputBlock.Text += Convert.ToString(falseFlag) & vbCrLf
outputBlock.Text += Convert.ToString(falseFlag).Equals(Boolean.FalseString) & vbCrLf
outputBlock.Text += Convert.ToString(trueFlag) & vbCrLf
outputBlock.Text += Convert.ToString(trueFlag).Equals(Boolean.TrueString) & vbCrLf
' The example displays the following output:
' False
' True
' True
' True
bool falseFlag = false;
bool trueFlag = true;
outputBlock.Text += Convert.ToString(falseFlag) + "\n";
outputBlock.Text += Convert.ToString(falseFlag).Equals(Boolean.FalseString) + "\n";
outputBlock.Text += Convert.ToString(trueFlag) + "\n";
outputBlock.Text += Convert.ToString(trueFlag).Equals(Boolean.TrueString) + "\n";
// The example displays the following output:
// False
// True
// True
// True
Version Information
Silverlight
Supported in: 5, 4, 3
Silverlight for Windows Phone
Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0
XNA Framework
Supported in: Xbox 360, Windows Phone OS 7.0
Platforms
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.