ToString Method
Collapse the table of content
Expand the table of content

Boolean::ToString Method ()

 

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

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

public:
virtual String^ ToString() override

Return Value

Type: System::String^

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

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.

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

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