Lab: the C# operators
Operators are the small symbols that do the work: add, compare, combine. There are fewer than you think, and they group neatly.
Arithmetic
Plus, minus, star and slash do what you expect. The percent sign gives the remainder, which is the usual way to test whether a number is even.
Comparison
Equal to, not equal to, greater than and less than each produce a boolean. Two equals signs compare; one equals sign assigns. Confusing the two is the single most common beginner mistake.
int a = 10;
int b = 3;
int remainder = a % b; // 1
bool isBigger = a > b; // true
bool bothTrue = isBigger && (b > 0);Logical
Two ampersands mean both conditions must hold. Two vertical bars mean either one may hold. A single exclamation mark reverses a boolean.
Operators only become useful once you can group statements, so continue to blocks of code and the semicolon.