C Sharp bool
From Coderwiki
More actions
The bool class in C# is a data type which can store one of two values:
truefalse
Booleans are especially useful when working with conditions.
See Boolean for general information about the uses and representation of boolean data types.
Size
edit edit sourceWhile a boolean could technically store a bool as a single bit, this wouldn't necessarily be optimal for memory layout.
For this reason, booleans in C# are stored as 1 byte in memory.
Keywords: true and false
edit edit sourceC# gives us two keywords for the boolean values true and false.
Example
edit edit sourcebool a = true;
bool b = false;
bool c = Convert.ToBoolean(1); // true
bool d = Convert.ToBoolean(0); // false