1/18
Flashcards covering key concepts related to Boolean types and operators in C#.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Boolean Type
A data type whose values can only be true or false.
Boolean Declaration
Can be declared using 'System.Boolean' or the 'bool' keyword.
Default Value of Booleans
False.
Less Than Operator
Specifies if the left hand side is less than the right hand side.
Greater Than Operator
Specifies if the left hand side is greater than the right hand side.
Less Than or Equal To Operator
Specifies if the left hand side is less than or equal to the right hand side.
Greater Than or Equal To Operator
Specifies if the left hand side is greater than or equal to the right hand side.
Equal To Operator
Checks if both sides are equal (equivalence operator). Uses two equal signs (==).
Not Equal Operator
Checks if both sides are not equal. Uses an exclamation mark followed by an equal sign (!=).
AND Operator
Returns true only if both operands are true.
OR Operator
Returns true if either or both operands are true.
Exclusive OR (XOR) Operator
Returns true if only one of the operands is true, but not if both are true.
AND Operators in C
Represented by one or two ampersand symbols (& or &&).
OR Operators in C
Represented by one or two pipe symbols (| or ||).
Exclusive OR Operator in C
Represented by the caret symbol (^).
Short Circuit Evaluation
Using double symbols (&&, ||) allows for short circuit evaluation, meaning the right hand side of an expression may not need to be evaluated.
Collecting Boolean Value from User
The user can enter 'true' or 'false' (in any case), but cannot enter similar values like 'yes' or 'no'.
Converting String to Boolean
Can be done using the 'Convert.ToBoolean' method or the 'Boolean.Parse' method.
Boolean to String Conversion
A Boolean can only be converted to a string, not an integral number. Achieved using string formatting methods.