TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

C# bool.TrueString and FalseString

This C# program shows the TrueString and FalseString fields.

TrueString, FalseString. Truth has a string representation. The bool.TrueString and bool.FalseString fields provide the string literals "True" and "False" for English. By using these fields, we represent truth values.

String LiteralBool Type: If True, False

Example. 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 return "True" and "False" in this program. But this is not guaranteed.

Public Static Readonly Field

Note: In other locales, it is possible they will return other strings. We compare these fields and use them just like normal strings.

C# program that demonstrates TrueString and FalseString

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

Literals. In programming, truth can be represented directly with the true and false literals. The string representation is available with the TrueString and FalseString fields. More information about boolean literals is available.

True, False

Summary. Programs often need these strings. TrueString and FalseString are a useful pair of readonly members. They represent truth values in string format. They provide indirection and abstraction over directly using string literals.


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf