Lesson 13: Logical operators
Sometimes a decision depends on several conditions together. In C# you combine booleans with symbols: && is 'and' (both must be true), || is 'or' (at least one is true), and ! is 'not' (flips true to false). Note: in C# these are symbols — not the words and/or/not.
&& is like a door needing two keys (both). || is a door any key opens (one is enough). ! flips yes to no.
- && (and)
- True only if both sides are true.
- || (or)
- True if at least one side is true.
- ! (not)
- Flips true to false and vice versa.
- symbols, not words
- In C# you use && || ! and not the words and/or/not.