07 January 2012

Naming conventions in .net

Pascal case


The first letter in the identifier and the first letter of each subsequent concatenated word are capitalized.


Example:

BackColor, DataSet


Camel case


The first letter of an identifier is lowercase and the first letter of each subsequent concatenated word is capitalized.


Example:

numberOfDays, isValid


Uppercase


All letters in the identifier are capitalized.


Example:

ID, PI


1).  Private Variables: _strFirstName, _dsetEmployees
2).  Local Variables: strFirstName, dsetEmployees

3).  Namespace:(Pascal) System.Web.UI, System.Windows.Forms

4).  Class Naming:(Pascal) FileStream, Button

5).  Interface Naming:(Pascal) IServiceProvider, IFormatable

6).  Parameter Naming:(Camel) pTypeName, pNumberOfItems

7).  Method Naming:(Pascal) RemoveAll(), GetCharAt()

7).  Method Parameters:(Camel) void SayHello(string name)....
8).  Property / Enumerations Naming:(Pascal) BackColor, NumberOfItems

9).  Event Naming:(Pascal) public delegate void MouseEventHandler(object sender, MouseEventArgs e);

10).  Exception Naming: catch (Exception ex){ }

11).  Constant Naming: AP_WIN, CONST

No comments: