#40 – TrueString and FalseString

The System.Boolean type (bool) provides two fields that let you get string representations of the true and false values.

 string trueText = bool.TrueString;      // "True"
 string falseText = bool.FalseString;    // "False"

These fields return “True” and “False”, regardless of current regional settings or the native language of the operating system.

These values are identical to the string values returned from the System.Boolean.ToString() method, which can be called on an instance of bool.

 bool b1 = true;
 bool b2 = false;

 string true2 = b1.ToString();     // "True"
 string false2 = b2.ToString();    // "False"
Advertisements