ADO.NET命名規範數組
數據類型ui |
數據類型簡寫spa |
標準命名舉例orm |
Connectionxml |
con對象 |
conNorthwind接口 |
Command事件 |
cmdci |
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 |
WinForm Control命名規範
數據類型 |
數據類型簡寫 |
標準命名舉例 |
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 |
WebControl命名規範
數據類型 |
數據類型簡寫 |
標準命名舉例 |
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 |
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 |
變量 變量的做用域及前綴
前綴 |
說明 |
舉例 |
P |
全局變量 |
pstrName |
St |
靜態變量 |
ststrName |
M |
模塊或者窗體的局部變量 |
MstrName |
A |
數組 |
AintCount[] |
變量數據類型的前綴
C#數據類型 |
類庫數據類型 |
標準命名舉例 |
Sbyte |
System.sbyte |
sbte |
Short |
System.Int16 |
sht |
Int |
System.Int32 |
int |
Long |
System.Int64 |
lng |
Byte |
System.Byte |
bte |
Ushot |
System.Uint16 |
usht |
Uint |
System.Uint32 |
uint |
Ulong |
System.Uint64 |
ulng |
Float |
System.Single |
flt |
Double |
System.Double |
dbl |
Decimal |
System.Decimal |
dcl |
Bool |
System.Boolean |
bol |
Char |
System.Char |
chr |
Object |
System.Object |
obj |
String |
System.String |
str |
|
System.DateTime |
dte |
IntPtr |
System.Intpre |
intptr |
常量定義 常量=做用域+ c+數據類型+變量名
類對象定義 類實例=做用域+cls+變量名 類對象=C+名稱
結構對象定義 結構對象實例=做用域+struc+變量名 結構對象=S+名稱
命名空間定義 以層爲前綴進行命名
接口定義 以大寫I爲前綴
窗體的命名規則 窗體名=frm+窗體名(名詞+動詞) 注意:保存的文件明和窗體名相同。
枚舉定義規則 以Enum爲前綴
事件命名規則 事件控制器要帶有EventHandler後綴 使用sender和e命名兩個參數 事件參數類要帶有EventArgs後綴 考慮使用動詞命名事件 對於有「以前」或「以後」概念的事件,要使用如今時或過去時命名