O'Reilly logo

C# 5.0 Unleashed by Bart De Smet

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required