
You want to get a string representation of truth values in your C# program. The bool.TrueString and bool.FalseString fields provide the string literals "True" and "False" for English. By using these fields, you can represent truth values.

To begin, these two fields are implemented as public static readonly fields. This means that a memory location must be accessed each time you use them. Also, they may return "True" and "False" in this program, but this is not guaranteed and in other locales, it is possible they will return other strings. You can compare these fields and use them just like normal strings.
Public Static Readonly FieldThis C# program shows the TrueString and FalseString fields.
Program that demonstrates TrueString and FalseString [C#]
using System;
class Program
{
static void Main()
{
// Write values of these properties.
Console.WriteLine(bool.TrueString);
Console.WriteLine(bool.FalseString);
Console.WriteLine();
Console.WriteLine(bool.TrueString == "True");
Console.WriteLine(bool.FalseString == "False");
}
}
Output
True
False
True
True
In programming, truth can be represented directly with the true and false literals. The string representation is available with the TrueString and FalseString fields as shown above. For more information about boolean literals, please consult the appropriate article.
True Value False ValueThe TrueString and FalseString fields are a useful pair of readonly members that can be used to appropriately represent truth values in string format. They provide another level of indirection and abstraction over using string literals directly.
String Literal Bool Type