Boolean.ToString Boolean.ToString Boolean.ToString Method

Definition

Converts the value of this instance to its equivalent string representation (either "True" or "False").

Overloads

ToString(IFormatProvider) ToString(IFormatProvider) ToString(IFormatProvider)

Converts the value of this instance to its equivalent string representation (either "True" or "False").

ToString() ToString() ToString()

Converts the value of this instance to its equivalent string representation (either "True" or "False").

ToString(IFormatProvider) ToString(IFormatProvider) ToString(IFormatProvider)

Converts the value of this instance to its equivalent string representation (either "True" or "False").

public:
 virtual System::String ^ ToString(IFormatProvider ^ provider);
public string ToString (IFormatProvider provider);
Public Function ToString (provider As IFormatProvider) As String
Parameters
Returns

TrueString if the value of this instance is true, or FalseString if the value of this instance is false.

Implements

Remarks

The provider parameter is reserved. It does not participate in the execution of this method. This means that the Boolean.ToString(IFormatProvider) method, unlike most methods with a provider parameter, does not reflect culture-specific settings.

This method returns the constants "True" or "False". Note that XML is case-sensitive, and that the XML specification recognizes "true" and "false" as the valid set of Boolean values. If the String object returned by the ToString(IFormatProvider) method is to be written to an XML file, its String.ToLowerInvariant method should be called first to convert it to lowercase.

ToString() ToString() ToString()

Converts the value of this instance to its equivalent string representation (either "True" or "False").

public:
 override System::String ^ ToString();
public override string ToString ();
Public Overrides Function ToString () As String
Returns

"True" (the value of the TrueString property) if the value of this instance is true, or "False" (the value of the FalseString property) if the value of this instance is false.

Examples

The following example illustrates the ToString method.

Boolean raining = false;
Boolean busLate = true;
Console::WriteLine(  "raining->ToString() returns {0}", raining.ToString() );
Console::WriteLine(  "busLate->ToString() returns {0}", busLate.ToString() );
// The example displays the following output:
//       raining.ToString() returns False
//       busLate.ToString() returns True
bool raining = false;
bool busLate = true;

Console.WriteLine("raining.ToString() returns {0}", raining);
Console.WriteLine("busLate.ToString() returns {0}", busLate);
// The example displays the following output:
//       raining.ToString() returns False
//       busLate.ToString() returns True
Dim raining As Boolean = False
Dim busLate As Boolean = True

Console.WriteLine("raining.ToString() returns {0}", raining)
Console.WriteLine("busLate.ToString() returns {0}", busLate)
' The example displays the following output:
'       raining.ToString() returns False
'       busLate.ToString() returns True

Remarks

This method returns the constants "True" or "False".

Note that XML is case-sensitive, and that the XML specification recognizes "true" and "false" as the valid set of Boolean values. If the string returned by the ToString() method is to be written to an XML file, its String.ToLowerInvariant method should be called first to convert it to lowercase.

Applies to