The Boolean Type

Boolean values, named after George Boole, are used to denote logical truth values. Named System.Boolean in the BCL, the type surfaces with the bool alias in C#. Only two Boolean values exist, both of which have an associated Boolean literal. Unsurprisingly, those are true and false.

Note: Memory representation and use

Although only 1 bit would be required to express true or false, Boolean values are represented by the CLR as 1 byte. You can see this from the Immediate window by evaluating the sizeof(bool) expression. This is really just an implementation detail, reflecting the smallest addressable unit of memory.

But from a typing perspective, there are really only two semantic values for the Boolean type: An all-zero pattern ...

Get C# 5.0 Unleashed now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.