C# Booleans with Examples

A bool (short for Boolean) variable may be a sort of box that may hold whether or not something is true. Sometimes that is all you want. If you're storing whether or not a subscription has been paid or not there is no got to waste space by using a type that can hold an outsized number of possible values. Instead, you only got to hold the states true or false. These are the only two values that the bool type allows.

Example:

bool student_status = true;
if (student_status == true)
{
	Console.WriteLine("Student enrollment is approved");

}
else
{
	Console.WriteLine("Student enrollment is not approved");
}

int number1 = 20;
int number2 = 10;
Console.WriteLine(number2 > number1);

Console.WriteLine(number1 < 100);
Console.WriteLine(number1 > number2);

Output:

Student enrollment is approved
False
True
True