Boolean Value in C#

Boolean value in c#. The. NET System is an alias for the bool type keyword. A Boolean value is a true or false value that can be represented by a Boolean structure type. Boolean logical operators are used to perform logical operations on bool values. The result type of comparison and equality operators is bool.

using System;

namespace Main
{
class Program
{
static void Main(string[] args)
{
bool isCSharpProgram = true;
bool isBadProgram = false;
Console.WriteLine(isCSharpProgram);
Console.WriteLine(isBadProgram);
}
}
}

 

Output:

True

False

Boolean Value in C#

The bool type can only store true or false values. Create a bool variable in the same way you would an int or string variable. Write the type name, ‘bool,’ then the variable name, and then, most likely, the variable’s initial value.

Bool or Boolean in C#

The value true/false in this example is placed directly in the variable because bool is a primitive type. A Boolean is a type of object. A reference to a Boolean object is stored in a variable of type Boolean. The only major distinction is in terms of storage.

Uses of Bool in C#

Keywords are terms in a language that indicate predetermined activities or are utilized for internal processes. The keyword bool is used to declare a variable that can store true or false Boolean values in program.