- Use tabs for indentation (no 4 spaces)
- Use
this.everywhere possibile. - Always specify the visibility, even if it's the default case. (e.g.
private string _foonotstring _foo). - Visibility should be the first modifier (e.g.
public abstractnotabstract public). - Avoid more than one blank line at one time. For example, do not have two blank lines between any lines of code).
- Avoid spurious free spaces. For example avoid
if (some_var == 0) {. (useif (some_var == 0) {; - Only use
varwhen the type is explicitly named on the right-hand side, tipically due to eithernewor an explicit cast, e.g.var stream = new FileStream(...)notvar stream = OpenStandardInput(). - We use language keywords instead of BCL types (e.g.
int, string, floatinstead ofInt32, String, Single, etc) for both type references as well as method calls (e.g.int.Parseinstead ofInt32.Parse). - Use
readonlywhere possible. When used on static fields,readonlyshould come afterstatic(e.g.static readonly). - Use
snake_casefor all fields and variables. - Prefix internal and private fields and local variables with
_and static fields withs_. - Use
camelCasefor all method names, including local functions. - Use
PascalCasefor all class and interface names. - Fields should be specified at the top within type declarations.
- When including non-ASCII characters in the source code use Unicode escape sequences (\uXXXX) instead of literal characters.
- When using a single-statement if, if possible, use a single-line form:
if (my_variable == 5) return true;. - Using braces is always accepted, and required for any nested blocks or if a single statement body spans multiple lines.
- No MAGIC NUMBERS, always use
enums!