This documentation is archived and is not being maintained.

Convert.ToString Method (Boolean)

.NET Framework 1.1

Converts the value of the specified Boolean to its equivalent String representation.

[Visual Basic]
Overloads Public Shared Function ToString( _
   ByVal value As Boolean _
) As String
public static string ToString(
 bool value
public: static String* ToString(
 bool value
public static function ToString(
   value : Boolean
) : String;


A Boolean value.

Return Value

The String equivalent of the value of value.


This implementation is identical to Boolean.ToString.


[Visual Basic, C#, C++] The following code sample illustrates the conversion of a Boolean to a String, using ToString.

[Visual Basic] 
Public Sub ConvertStringBoolean(ByVal stringVal As String)

    Dim boolVal As Boolean = False

        boolVal = System.Convert.ToBoolean(stringVal)
        If boolVal Then
            System.Console.WriteLine( _
                "String is equal to System.Boolean.TrueString.")
            System.Console.WriteLine( _
                "String is equal to System.Boolean.FalseString.")
        End If
    Catch exception As System.FormatException
        System.Console.WriteLine( _
            "The string must equal System.Boolean.TrueString " + _
            "or System.Boolean.FalseString.")
    End Try

    ' A conversion from bool to string will always succeed.
    stringVal = System.Convert.ToString(boolVal)
    System.Console.WriteLine("{0} as a String is {1}", _
                              boolVal, stringVal)
End Sub

public void ConvertStringBoolean(string stringVal) {
    bool boolVal = false;

    try {
        boolVal = System.Convert.ToBoolean(stringVal);
        if (boolVal) {
                "String was equal to System.Boolean.TrueString.");
        else {
                "String was equal to System.Boolean.FalseString.");
    catch (System.FormatException){
            "The string must equal System.Boolean.TrueString " +
            "or System.Boolean.FalseString.");

    // A conversion from bool to string will always succeed.
    stringVal = System.Convert.ToString(boolVal);
    System.Console.WriteLine("{0} as a string is {1}",
        boolVal, stringVal);


   void ConvertStringBoolean(String* stringVal)
      bool boolVal = false;

      try {
         boolVal = System::Convert::ToBoolean(stringVal);
         if (boolVal) {
            System::Console::WriteLine(S"String was equal to System::Boolean::TrueString.");
         } else {
            System::Console::WriteLine(S"String was equal to System::Boolean::FalseString.");
      } catch (System::FormatException*) {
         System::Console::WriteLine(S"The String* must equal System::Boolean::TrueString or System::Boolean::FalseString.");

      // A conversion from bool to String* will always succeed.
      stringVal = System::Convert::ToString(boolVal);
      System::Console::WriteLine(S" {0} as a String* is {1}",
         __box(boolVal), stringVal);

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

See Also

Convert Class | Convert Members | System Namespace | Convert.ToString Overload List