C#命名规范(参考) (II)

C#命名规范(参考)

1.Class命名:采用Pascal方式,不加任何前缀或后缀,在微软给出的建议中认为这些是冗余信息。
2.Method命名:采用Pascal方式,使用动词或动词短语,如Remove();或GetCharArray();等。
3.参数命名: 采用Camel方式,微软反对使用匈牙利命名方式,认为匈牙利命名方式与具体编程语言

相关并且维护复杂,建议使用代表参数意义的名字。
4.Field命名:对于public、protected或internal修饰的采用Pacal风格,提倡避免使用,如需使用

可以用propety代替;对于private的采用Camel风格并以下划线(_)为前缀,微软不在提倡以m_为前

缀的field命名方式。
5.对于Static或Const变量参见第4条。
6.Propety命名:采用Pascal格式,命名要反映出对应的实体,并且不要以“Get”或“Set”为前缀


7.Variable命名:采用Camel格式,反映出变量代表的意思。
8.Interface命名:采用Pascal格式,以I为前缀。
9.使用Attribute作为自定义属性类的后缀

10.使用Exception作为自定义异常处理类的后缀
11.Naming Space命名:公司名称.技术名称[.Feature][.Design],如System.Window.Form
//文件命名
Project:Pascal格式,总是和联编以及根命名空间相同。
Source File文件:总是和类名相匹配,避免一个文件包含多个类的情况。


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控件
web控件名 缩写
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 vs
XML XML
        
  b、html控件
html控件名 缩写
HtmlAnchor hah
HtmlButton hbtn
HtmlForm hform
HtmlGenericControl hgc
HtmlImage himg
HtmlInputButton(按钮) htxt
HtmlInputButton(重置) hrbtn
HtmlInputButton(提交) hcbtn
HtmlInputCheckBox hick
HtmlInputFile hifile
HtmlInputHidden hihidden
HtmlInputImage hiimg
HtmlInputRadioButton hirb
HtmlInputText(密码) hpwd
HtmlInputText(文本) hitxt
HtmlSelect hslt
HtmlTable htab
HtmlTableCell htc
HtmlTableRow htr
HtmlTextArea htxta
c.ADO.NET控件命名规范
类型 前缀 示例
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


QQ:413708116 仅作技术交流
原文地址:https://www.cnblogs.com/ywcz060/p/1572737.html