变量,方法,类命名规则
2017-02-14 10:37
190 查看
命名规则:
名称空间,类,基类中的成员 用 Pascal 形式 例如: namespace MaxLength
私有成员用 camel 例如 private int subscriberId
成员字段常用一条下划线 例如: private int _subscriberId
传递给方法的所有参数名称camel public void RecordSale(string SalesmanName)
camel 大小写也用于区分2个对象
class SalesmanName
Pascal 规则
每个单词开头的字母大写(如 TestCounter).
Camel 规则
除了第一个单词外的其他单词的开头字母大写. 如. testCounter
命名规范的总结用表格表示如下:
与类相关:
与变量命名相关(根据不同的数据类型前缀+首字母大写的变量描述)
与ADO.NET有关
与页面控件有关(html标签)
与页面控件有关(html标签)
名称空间,类,基类中的成员 用 Pascal 形式 例如: namespace MaxLength
私有成员用 camel 例如 private int subscriberId
成员字段常用一条下划线 例如: private int _subscriberId
传递给方法的所有参数名称camel public void RecordSale(string SalesmanName)
camel 大小写也用于区分2个对象
class SalesmanName
Pascal 规则
每个单词开头的字母大写(如 TestCounter).
Camel 规则
除了第一个单词外的其他单词的开头字母大写. 如. testCounter
命名规范的总结用表格表示如下:
与类相关:
标识符 | 大小写 | 示例 |
类/结构 | Pascal | AppDomain |
枚举类型 | Pascal | ErrorLevel |
枚举值 | Pascal | FatalError |
事件 | Pascal | ValueChange |
异常类 | Pascal | WebException 注意 总是以 Exception 后缀结尾。 |
只读的静态字段 | Pascal | RedValue |
接口 | Pascal | IDisposable 注意 总是以 I 前缀开始。 |
集合 | Pascal | CustomerCollection 注意 总是以Collection结束 |
方法 | Pascal | ToString |
命名空间 | Pascal | System.Drawing |
参数 | Camel | typeName |
属性 | Pascal | BackColor |
受保护的实例字段 | Camel | redValue 注意 很少使用。属性优于使用受保护的实例字段。 |
公共实例字段 | Pascal | RedValue 注意 很少使用。属性优于使用公共实例字段。 |
类型 | 前缀 | 示例 |
Array | arr | arrShoppingList |
Boolean | bln | blnIsPostBack |
Byte | byt | bytPixelValue |
Char | chr | chrDelimiter |
DateTime | dtm | dtmStartDate |
Decimal | dec | decAverageHeight |
Double | dbl | dblSizeofUniverse |
Integer | int | intRowCounter |
Long | lng | lngBillGatesIncome |
Object | obj | objReturnValue |
Short | shr | shrAverage |
Single | sng | sngMaximum |
String | str | strFirstName |
数据类型 | 数据类型简写 | 标准命名举例 |
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 |
数据类型 | 数据类型简写 | 标准命名举例 |
Label | lbl | lblMessage |
LinkLabel | llbl | llblToday |
Button | btn | btnSave |
TextBox | txt | txtName |
MainMenu | mmnu | mmnuFile |
CheckBox | chk | chkStock |
RadioButton | rbtn | rbtnSelected |
GroupBox | gbx | gbxMain |
PictureBox | pic | picImage |
Panel | pnl | pnlBody |
DataGrid | dgrd | dgrdView |
ListBox | lst | lstProducts |
CheckedListBox | clst | clstChecked |
ComboBox | cbo | cboMenu |
ListView | lvw | lvwBrowser |
TreeView | tvw | tvwType |
TabControl | tctl | tctlSelected |
DateTimePicker | dtp | dtpStartDate |
HscrollBar | hsb | hsbImage |
VscrollBar | vsb | vsbImage |
Timer | tmr | tmrCount |
ImageList | ilst | ilstImage |
ToolBar | tlb | tlbManage |
StatusBar | stb | stbFootPrint |
OpenFileDialog | odlg | odlgFile |
SaveFileDialog | sdlg | sdlgSave |
FoldBrowserDialog | fbdlg | fgdlgBrowser |
FontDialog | fdlg | fdlgFoot |
ColorDialog | cdlg | cdlgColor |
PrintDialog | pdlg | pdlgPrint |
数据类型 | 简写 | 举例 |
AdRotator | adrt | Example |
Button | btn | btnSubmit |
Calendar | cal | calMettingDates |
CheckBox | chk | chkBlue |
CheckBoxList | chkl | chklFavColors |
CompareValidator | valc | valcValidAge |
CustomValidator | valx | valxDBCheck |
DataGrid | dgrd | dgrdTitles |
DataList | dlst | dlstTitles |
DropDownList | drop | dropCountries |
HyperLink | lnk | lnkDetails |
Image | img | imgAuntBetty |
ImageButton | ibtn | ibtnSubmit |
Label | lbl | lblResults |
LinkButton | lbtn | lbtnSubmit |
ListBox | lst | lstCountries |
Panel | pnl | pnlForm2 |
PlaceHolder | plh | plhFormContents |
RadioButton | rad | radFemale |
RadioButtonList | radl | radlGender |
RangeValidator | valg | valgAge |
Regularexpression_r | vale | valeEmail_Validator |
Repeater | rpt | rptQueryResults |
RequiredFieldValidator | valr | valrFirstName |
Table | tbl | tblCountryCodes |
TableCell | tblc | tblcGermany |
TableRow | tblr | tblrCountry |
TextBox | txt | txtFirstName |
ValidationSummary | vals | valsFormErrors |
XML | xmlc | xmlcTransformResults |
相关文章推荐
- Python 中特殊变量/方法命名规则说明(特别是私有变量)及使用实例
- 变量的命名规则(方法)
- Python 中特殊变量/方法命名规则说明(特别是私有变量)及使用实例
- Java标识符(包, 类, 接口, 方法, 变量等)中常见的命名规则
- Java中类、接口、变量、方法、属性、常量的命名规则
- [黑马程序员] _变量的基本使用方法(赋值、占位符、接收、命名规则)
- 变量名命名规则,构造方法的作用,类名命名规则
- Python变量、方法、类的命名规则
- 【Java基础】包、类、接口、常量、方法、变量的命名规则
- [黑马程序员] _变量的基本使用方法(赋值、占位符、接收、命名规则)
- 方法、变量与常量的命名规则
- MFC变量命名示例 & 单词缩写规则
- php变量 命名规则
- 变量命名规则
- 【编程好习惯】通过命名规则区分变量 推荐
- asp.net里的变量命名规则
- 养成良好的代码风格---c#变量命名规则
- JavaScript 变量命名规则
- javascript中的命名规则和方法
- javascript 命名规则 变量命名规则