C # Coding specification (1): naming rules

Source: Internet
Author: User

After working for a while, I found that the code development specification in the company had a big problem. I personally developed it based on my preferences.

I have summarized the development specifications that I think are more appropriate!

1. Class Name, attribute name, method name, file name in Pascal case format

2. variables. The method parameters are in the Camel case format.

3. Use meaningful and descriptive words to name variables
-Do not use the abbreviation. Use name, address, salary, and so on to replace nam, addr, sal
-Do not use single-letter variables such as I, n, x. Use index, temp, etc.
Variable exceptions used for loop iteration:
For (int I = 0; I <count; I ++ ){...}
If a variable is used only for iterative counting and does not appear elsewhere in the loop, many people prefer to use a single letter variable (I) instead of another name.
-The variable name does not contain underscores (_).
-The namespace must be named in standard mode.

4. The file name must match the class name.
For example, for the class HelloWorld, the corresponding file name should be helloworld. cs (or, helloworld. vb)

5. Three-layer naming rules

Entity layer: ClassInfo

Data Layer: DalClass (the same method should be named as uniform as possible). For example, each class has the Add Edit Delete method to Get the data prefix and Get

Business logic layer: BllClass

 

6. aspx File naming rules

PageNameAdd

PageNameList

PageNameEdit

 

7. Control naming

Control Prefix Example
Label Lbl LblSurname
TextBox Txt TxtSurname
DataGrid Dg DgResults
Button Btn BtnSave
ImageButton Ibtn IbtnSave
Hyperlink Lnk LnkHomePage
DropDownList Ddl DdlCompany
ListBox Lst LstCompany
DataList Dlst DlstAddress
Repeater Rep Rection
Checkbox Chk ChkMailList
CheckBoxList Chk ChkAddress
RadioButton Rdo RdoSex
RadioButtonList Rdo RdoAgeGroup
Image Img ImgLogo
Panel Pan PanSection
PlaceHolder Plh PlhHeader
Calender Cal CalMyDate
Adrotator Adr AdrBanner
Table Tbl TblResults
[All] Validators Val ValCreditCardNumber
ValidationSummary Vals ValsErrors

 

8 generic naming rules

IList <ExhibitorInfo> ILExhibitorInfo = new List <ExhibitorInfo> ()

 

Pascal case-the first letter of all words is in upper case, and the other letters are in lower case.
Camel case-except the first word, the first letter and other letters of all words are in upper case.

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.