Ask Learn
Preview
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Converts the value of this instance to its equivalent string representation (either "True" or "False").
ToString(IFormatProvider) |
Converts the value of this instance to its equivalent string representation (either "True" or "False"). |
ToString() |
Converts the value of this instance to its equivalent string representation (either "True" or "False"). |
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 string ToString(IFormatProvider provider);
override this.ToString : IFormatProvider -> string
Public Function ToString (provider As IFormatProvider) As String
(Reserved) An IFormatProvider object.
TrueString if the value of this instance is true
, or FalseString if the value of this instance is false
.
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.
Product | Versions |
---|---|
.NET | Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |
Converts the value of this instance to its equivalent string representation (either "True" or "False").
public:
override System::String ^ ToString();
public override string ToString();
override this.ToString : unit -> string
Public Overrides Function ToString () As String
"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
.
The following example illustrates the ToString method.
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
let raining = false
let busLate = true
printfn $"raining.ToString() returns {raining}"
printfn $"busLate.ToString() returns {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
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.
Product | Versions |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1 |
UWP | 10.0 |
.NET feedback
.NET is an open source project. Select a link to provide feedback:
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign in