Export (0) Print
Expand All

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 override string ToString ()
public String ToString ()
public override function ToString () : String
Not applicable.

Return Value

TrueString if the value of this instance is true, or FalseString 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 object returned by the ToString method is to be written to an XML file, its String.ToLower method should be called first to convert it to lowercase.

The following code sample illustrates the use of ToString in the context of Boolean.

bool raining = false;
bool busLate = true;

Console.WriteLine("raining.ToString() returns {0}", raining);
Console.WriteLine("busLate.ToString() returns {0}", busLate);

boolean raining = false;
boolean busLate = true;
      
Console.WriteLine("raining.ToString() returns {0}",
    (System.Boolean)raining);
Console.WriteLine("busLate.ToString() returns {0}",
    (System.Boolean)busLate);

var raining : Boolean  = false;
var busLate : Boolean = true;

Console.WriteLine("raining.ToString() returns {0}", raining);
Console.WriteLine("busLate.ToString() returns {0}", busLate);

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

XNA Framework

Supported in: 1.0

Community Additions

ADD
Show:
© 2014 Microsoft