Coding Standards and Naming Conventions
Indenting and Whitespace
Use an indent of 2 spaces, with no tabs. Lines should have no trailing whitespace at the end.
All binary operators (operators that come between two values), such as , -, =, !=, ==, >, etc. should have a space before and after the operator, for readability. Unary operators (operators that operate on only one value), such as
+, should not have a space between the operator and the variable or number they are operating on.
Do not put a space between the (type) and the variable in a cast. In case when it’s possible to us “as” keyword it’s better to use it, instead of cast.
You are strongly encouraged to always use curly braces even in situations where they are technically optional. Having them increases readability and decreases the likelihood of logic errors being introduced when new lines are added.
Class names must be nouns or noun phrases. Use Pascal Casing. Do not use any class prefix.
Name interfaces with nouns or noun phrases or adjectives describing behavior. Use Pascal Casing. Use ’I’ as prefix for the name, it is followed by a capital letter (first char of the interface name).
Use Pascal Casing for enum value names and enum type names. Don’t prefix (or suffix) a enum type or enum values.
Const Field Names
Name const fields with nouns, noun phrases or abbreviations for nouns. Use Pascal Casing.
Do use descriptive names, which should be enough to determine the variable meaning and it’s type. But prefer a name that’s based on the parameter’s meaning. Use Camel Casing.
Non const field Names
Do use descriptive names, which should be enough to determine the variable meaning and it’s type. But prefer a name that’s based on the parameter’s meaning. Use Camel Casing. Use ‘_’ as prefix(first char of the field name).
Counting variables are preferably called i, j, k, l, m, n when used in 'trivial' counting loops. Use Camel Casing.
Name methods with verbs or verb phrases. Use Pascal Casing.
Name properties using nouns or noun phrases. Use Pascal Casing.
Consider naming a property with the same name as it’s type
Name event handlers with the EventHandler suffix. Use two parameters named sender and e. Use Pascal Casing. Name event argument classes with the EventArgs suffix. Name event names that have a concept of pre and post using the present and past tense. Consider
naming events using a verb.
Download code samples