Identifier | Casing | Example |
Class, Struct | Pascal | StrategyManager |
Interface | Pascal with I prefix | IStrategy |
Enumeration | Pascal | LoggingLevel |
Enumeration Value | Pascal | Info |
Enumeration Representing Bit Field | Pascal in plural | SearchOptions |
Event | Pascal | Click |
Private Field | Camel with underscore | _scheduler |
Protected Field | Camel with underscore | _scheduler |
Constant Field | Pascal | Pi |
Constant Variable | Camel | definitionKey |
Readonly Field | Camel with underscore | _listItems |
Static Readonly Field | Pascal | ListValues |
Variable | Camel | value |
Method | Pascal | ComputeValue |
Property | Pascal | Value |
Parameter | Camel | parameter |
Type Parameter | Pascal with T prefix | TValue |
Namespace | Pascal | System.Drawing |
Abbreviation with 2 and less letters | All Caps | UI, IO |
Abbreviation with 3 and more letters | Pascal | Xml, Http |
Use Proper Class Layout
Use the following order to position all your members inside the class. The resulting layout is the combination of all the lists provided with descending priority. That means that on the top of the file there will be all public const fields followed by internal const fields.
1. Fields
2. Delegates
3. Events
4. Properties
5. Indexers
6. Constructors
7. Finalizers
8. Methods
9. Other stuff
Than follow access modifier.
1. public
2. internal
3. protected
4. private
After access modifier follow the type of the member.
1. const
2. static
3. readonly
4. nothing
The least significant sorting attribute is a declaration modifier.
1. virtual
2. abstract
3. override
4. new