Naming Conventions and Styles
Use Pascal casing for type and method names and constants:
public class SomeClass { const int DefaultSize = 100; public SomeMethod() {} }
Use camel casing for local variable names and method arguments:
int number; void MyMethod(int someNumber) {}
Prefix interface names with
I:interface IMyInterface {..}Prefix private member variables with
m_.Suffix custom attribute classes with
Attribute.Suffix custom exception classes with
Exception.Name methods using verb/object pairs, such as
ShowDialog().Methods with return values should have names describing the values returned, such as
GetObjectState().Use descriptive variable names.
Avoid single-character variable names, such as
iort. Useindexortempinstead.Avoid using Hungarian notation for public or protected members.
Avoid abbreviating words (such as
numinstead ofnumber).
Always use C# predefined types, rather than the aliases in the
Systemnamespace. For example:object NOT Object string NOT String intNOT Int32
With generics, use capital letters for types. Reserve suffixing
Typefor when dealing with the .NET typeType://Correct: public class LinkedList<K,T> {...} //Avoid: public class LinkedList<KeyType,DataType> {...}Use meaningful namespace names, such as the product name or the company name.
Avoid fully qualified type names. Use the
usingstatement instead.Avoid putting a
usingstatement inside a namespace.Group all framework namespaces together and put custom or third-party namespaces underneath:
using System; ...