Updated: This article has been updated and re-posted. See hereCapitialisation Styles
Style | Notes | Example |
Pascal case, TitleCase | The first letter in the identifier and the first letter of each subsequent word are capitalised. You can use Pascal case for identifiers of three or move characters. | BackColor |
Camel case | The first letter of an identifier is lowercase and the first letter of each subsequent word is capitalised. | backColor |
Uppercase | All letters in the identifier are capitalised. Use this convention only for identifiers that consist of two or fewer letters. | System.IO |
Code Structure
Variable Names
Status: Proposed 23rd May ’05 by Al Gardner.
All variables, properties, methods, enumerations and constants should be named differently enough so that their scope is apparent, i.e.
Scope | Types | Standard | Examples |
Global | Anything available throughout the entire application. Includes Namespaces, class definitions and enumerated types defined in a Namespace | TitleCase | namespace MyCompany.Bank.Example { enum Issuer { Government, Corporate } public class Bond {…} |
Class Public | Anything that a class exposes to the rest of its namespace, or another namespace that is using the namespace. Includes the enumerations, properties and methods | TitleCase | public class Bond { enum Issuer { Government, Corporate } public override string ToString() {…} |
Class private | Anything defined that is available within the class. Usually just private or protected member variables. | _camelCase | public class Bond { private int _entityId; |
Method private | Objects that will go out of scope and the end of the method or property, includes local variables and parameters | camelCase | public double Years(DateTime marketDate) { StringBuilder result = new StringBuilder(); |
N.B. If you need to use this to make the scope apparent to the compiler, then you have broken these rules.