C# Booleans
True or False values.
C# Booleans
Very often, in programming, you will need a data type that can only have one of two values, like:
- YES / NO
- ON / OFF
- TRUE / FALSE
For this, C# has a bool data type, which can take the values true or false.
Boolean Expression
A Boolean expression returns a boolean value: true or false, by comparing values/variables.
Examples
Boolean Values
Declaring boolean variables.
using System;
class Program
{
static void Main(string[] args)
{
bool isCSharpFun = true;
bool isFishTasty = false;
Console.WriteLine(isCSharpFun); // Outputs True
Console.WriteLine(isFishTasty); // Outputs False
}
}