Lesson 50 +10 XP

Cheatsheet: Keywords & Operators

Cheatsheet: Keywords & Operators

A quick tour of the reserved words and symbols that make up C#.

Common keywords

CategoryKeywords
Typesint, string, bool, double, var, void
Classes/OOPclass, interface, abstract, sealed, virtual, override, new
Accesspublic, private, protected, internal
Flowif, else, switch, case, break, continue
Loopsfor, foreach, while, do
Methodsstatic, void, return, params
Errorstry, catch, finally, throw
Othersusing, namespace, const, readonly, enum, struct, async, await

You cannot use these as variable names.

Operator quick table

CategoryOperators
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.