Loading lessons...
Cheatsheet: Keywords & Operators
Cheatsheet: Keywords & Operators
A quick tour of the reserved words and symbols that make up C#.
Common keywords
| Category | Keywords |
|---|---|
| Types | int, string, bool, double, var, void |
| Classes/OOP | class, interface, abstract, sealed, virtual, override, new |
| Access | public, private, protected, internal |
| Flow | if, else, switch, case, break, continue |
| Loops | for, foreach, while, do |
| Methods | static, void, return, params |
| Errors | try, catch, finally, throw |
| Others | using, namespace, const, readonly, enum, struct, async, await |
You cannot use these as variable names.
Operator quick table
| Category | Operators | ||
|---|---|---|---|
| Arithmetic | + - * / % ++ -- | ||
| Assignment | = += -= *= /= %= | ||
| Comparison | == != > < >= <= | ||
| Logical | `&& | !` | |
| Ternary | ? : | ||
| Null | ?? ?. | ||
| Cast | (type) |
TL;DR
- Keywords are reserved - you can't use them as names.
- Operators power math, logic, and flow.
??and?.are the modern null helpers.