C # naming rules (reference)

Source: Internet
Author: User
Two naming methods:
Pascal: the first letter of each word is uppercase.
CAMEL: lowercase for the first word and uppercase for other words

1. Class naming: The Pascal method is used without any prefix or suffix. in Microsoft's suggestion, this information is considered redundant.
2. Method Name: Use Pascal and verb or verb phrase, such as remove (); or getchararray.
3. Parameter naming: using the camel method, Microsoft opposed to using the Hungary naming method, and thought that the Hungary naming method and the specificProgramming Language

Related and complex maintenance. We recommend that you use a name that represents the meaning of the parameter.
4. Field naming: The Pacal style is used for public, protected, or internal modification. We recommend that you do not use it if necessary.

You can use propety instead. For private, the camel style is prefixed with the following underscore (_). Microsoft does not advocate M _ as the prefix.

Field naming method.
5. For static or const variables, see article 4th.
6. propety naming: The name must reflect the corresponding entity in Pascal format, and should not be prefixed with "get" or "set ".

.
7. variable name: uses the camel format to reflect the meaning of the variable.
8. Interface naming: Use Pascal format and use I as the prefix.
9. Use attribute as the suffix of the custom attribute class

10. Use exception as the suffix of the custom exception handling class
11. Naming space name: company name. Technical name [. Feature] [. Design], such as system. Window. Form
// File name
Project: In PASCAL format, it is always the same as the combination and root namespace.
Source File: Always matches the class name to prevent a file from containing multiple classes.

1. Textbox (txt)
2. dropdownlist (list)
3. requiredfieldvalidator (VAL)
4. Label (LAB)
5. checkbox (chk)
6. imagebutton (BTN)
Eg: txtfirstname // listcountry // valfirstname // lblfirstname // chkshowfavorites // btnupdate

A. Web controls
Web Control name
Adrotator Art
Button BTN
Calendar CD
Checkbox CHK
Checkboxlist chkl
Comparevalidator CPV
Customvalidator CTV
DataGrid DG
Datalist DL
Dropdownlist DDL
Hyperlink HL
Image img
Imagebutton ibtn
Label lab
Linkbutton lbtn
ListBox lst
Panel pl
Placeholder pH
Radiobutton Rb
Radiobuttonlist RBL
Rangevalidator RV
Regularexpressionvalidator Rev
Repeater RP
Requiredfieldvalidator rfv
Table TB
Tablecell TC
Tablerow tr
Textbox txt
Validationsummary
XML

B. html controls
Abbreviation of HTML Control
Htmlanchor hah
Htmlbutton hbtn
Htmlform hform
Htmlgenericcontrol HGC
Htmlimage himg
Htmlinputbutton (button) htxt
Htmlinputbutton (reset) hrbtn
Htmlinputbutton (submitted) hcbtn
Htmlinputcheckbox hick
Htmlinputfile hifile
Htmlinputhidden hihidden
Htmlinputimage hiimg
Htmlinputradiobutton hirb
Htmlinputtext (password) hpwd
Htmlinputtext (text) hitxt
Htmlselect hslt
Htmltable htab
Htmltablecell HTC
Htmltablerow hTR
Htmltextarea htxta
C. Ado. Net Control naming rules
Type prefix example
Connection con connorthwind
Command cmd cmdreturnproducts
Parameter parm parmproductid
Dataadapter dad dadproducts
Datareader DTR dtrproducts
Dataset DST dstnorthwind
Datatable dtbl dtblproduct
Datarow Drow drowrow98
Datacolumn dcol dcolproductid
Datarelation drel drelmasterdetail
Dataview dvw dvwfilteredproducts

Related Article

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.