bool (C#)

bool is the C# type for a value that is either true or false. Booleans come from comparisons and conditions, and they drive if-statements and loops.

C#

Unlike some languages, C# requires an actual bool in conditions — you can't use a number like 1 or 0 in an if-statement. The values must be lowercase true and false.

bool is an alias for System.Boolean. Comparison operators like ==, !=, <, and > all produce bool results.

Examples

C#

bool isOpen = true;
bool result = 5 > 3;
Console.WriteLine(isOpen);
Console.WriteLine(result);

Output:

True
True

Learn it in a lesson

See also

Back to the Dictionary