1 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
|
数据类型
|
数据类型简写
|
标准命名举例
|
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
|
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
|
public class SomeClass { const int DefaultSize=100; public SomeMethod() { } } |
int number;
void MyMethod(int someNumber)
{}
|
interface ImyInterface
{…}
|
public class SomeClass
{
private int m_Number;
}
|
//
正确
public class LinkedList<K,T>
{…}
//
避免
public class LinkedList<KeyType,DataType>
{….}
|
using System;
using System.Collection.Generic;
using System.ComponentModel;
using System.Data;
using MyCompany;
using MyControls;
|
delegate void SomeDelegate();
public void SomeMethod()
{…}
SomeDelegate someDelegate=SomeMethod;
|
public class MyClass
{
int m_Number;
string m_Name;
public void SomeMethod1();
public void SomeMethod2();
}
|
// In MyClass.cs
public partial class MyClass
{…}
//In MyClass.Designer.cs
public partial class MyClass
{…}
|
public class MyClass
{
public const int DaysInWeek=7;
pubic readonly int Number;
public MyClass(int someValue)
{
Number=someValue;
}
}
|
using System.Diagnostics;
object GetObject()
{…}
object someObject=GetObject();
Debug.assert(someObject!=null);
|
catch(Exception exception)
{
MessageBox.Show(exception.Message);
throw;//
或
throw exception;
}
|
//
正确
public enum Color
{
Red,Green,Blue
}
//
避免
public enum Color
{
Red=1,Green=2,Blue=3
}
|
//
避免
public enum Color:long
{
Red,Green,Blue
}
|
Bool IsEverythingOK()
{…}
//
避免
if(IsEverythingOk())
{…}
//
正确
bool ok=IsEverythingOK();
if (ok)
{…}
|
public class MyClass
{}
const int ArraySize=100;
MyClass[] array=new MyClass[ArraySize];
For (int index=0;index<array.Length;index++)
{
array[index]=new MyClass();
}
|
Dog dog=new GermanShepherd();
GermanShepherd shepherd=dog as GermanShepherd;
if (shepherd!=null)
{…}
|
Public class MyPublisher
{
MyDelegate m_SomeEvent;
Public event MyDelegate SomeEvent
{
add
{
m_SomeEvent+=value;
}
remove
{
m_SomeEvent-=value;
}
}
}
|
SomeType obj1;
ImyInterface obj2;
/*Some code to initialize obj1,then:*/
obj2=obj1 as ImyInterface;
if(obj2!=null)
{
obj2.Method1();
}
else
{
//Handle erro in expected interface
}
|
//
避免
string name=””;
//
正确
string name=String.Empty;
|
int number=SomeMethod();
swith(number)
{
case 1:
trace.WriteLine(“Case 1:”)
break;
case 2:
trace.Writeline(“Case 2:”);
break;
default:
debug.Assert(false);
break;
}
|
//Example of proper use of ‘this’
public class MyClass
{
public MyClass(string message)
{ }
public MyClass():this(“Hello”)
{ }
}
|
//Example of proper use of ‘base’
public class Dog
{
public Dog(string name)
{ }
virtual public void Bark(int howlong)
{ }
}
public class GermanShepherd:Dog
{
public GermanShepherd(string name):base(name)
{ }
override public void Bark(int howLong)
{
base.Bark(howLong)
}
}
|
Int CalcPower(int number,int power)
{
int result=1;
for (int count=1;count<=power;count++)
{
checked
{
result*=number;
}
}
return result;
}
|
public class MyClass
{
[Conditional(“MySpecialCondition”)]
<script language=JavaScript> function GetQuote(id) { //www.cnblogs.com.ICommentService.GetCommentText(id,SetQuote); BlogServer.WebService.AjaxWS.GetComment(id,SetQuote); } function SetQuote(result) { document.getElementById('AjaxHolder_PostComment_tbComment').value += ("--引用--------------------------------------------------/n"+result+"/n--------------------------------------------------------/n"); document.getElementById('AjaxHolder_PostComment_tbComment').focus(); } function Favorite(entryID,title,url,element) { document.getElementById(element.id).innerHTML = "正在收藏..."; BlogServer.WebService.AjaxWS.AddToFavorites(entryID,title,url,OnFavoriteSuccess); document.getElementById(element.id).removeAttribute("href"); document.getElementById(element.id).removeAttribute("onclick"); } function OnFavoriteSuccess(result) { if(result == "请先登录") { window.location.href = "../../../../../login.aspx?ReturnUrl=" + window.location.href; } else { var returnstr = result.split(","); var id = "lnkFavorite"+returnstr[0]; document.getElementById(id).innerHTML = "" + returnstr[1] + ""; } } </script>公告
QQ
群:
8025234
(验证:
C#.NET
)
专注于
.NET
技术
郑重申明:
1.
如文章标题中注明
“
搜藏
”
字样,即表明该文章是
“
转载
”
,特此申明!
2.
如需转载本
blog
文章,请注明出处,谢谢合作!
访问统计: |
| |||||||||
日
|
一
|
二
|
三
|
四
|
五
|
六
| |||
29
|
30
|
31
|
1
|
2
|
3
|
4
| |||
6
|
7
|
8
|
10
|
11
| |||||
12
|
13
|
14
|
15
|
16
|
17
|
18
| |||
19
|
20
|
21
|
22
|
23
|
24
|
25
| |||
27
|
28
|
29
|
30
|
31
|
1
| ||||
2
|
3
|
4
|
5
|
6
|
7
|
8
|
数据类型
|
数据类型简写
|
标准命名举例
|
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
|
控件类型
|
缩写
|
示例
|
Animated button
|
ani
|
aniMailBox
|
Button
|
btn
|
|
Check box
|
chk
|
chkReadOnly
|
ColorDialog
|
clrdlg
|
|
Combobox,drop-down list box
|
cbo
|
cboEnglish
|
Communications
|
com
|
comFax
|
ContextMenu
|
ctxmnu
|
|
Control(used within procedures when the specific type is unknown)
|
ctr
|
ctrCurrent
|
CrystalReportViewer
|
crvw
|
|
Data
|
dat
|
datBiblio
|
Data grid
|
dgd
|
dgdTitles
|
Data list
|
dbl
|
dblPublisher
|
Data repeater
|
drp
|
drpLocation
|
Data-bound combo box
|
dbcbo
|
dbcboLanguage
|
Data-bound grid
|
dbgrd
|
dbgrdQueryResult
|
Data-bound list box
|
dblst
|
dblstJobType
|
Datetime picker
|
dtp
|
dtpPublished
|
Directory list box
|
dir
|
dirSource
|
DomainUpDown
|
dupd
|
|
Drive list box
|
drv
|
drvTarget
|
ErrorProvider
|
err
|
|
File list box
|
fil
|
filSource
|
Flat scroll bar
|
fsb
|
fsbMove
|
FontDialog
|
fntdlg
|
|
Form
|
frm
|
frmEntry
|
Frame
|
fra
|
fraLanguage
|
Gauge
|
gau
|
gauStatus
|
Graph
|
gra
|
graRevenue
|
Grid
|
grd
|
grdPrices
|
GroupBox
|
grp
|
|
HelpProvider
|
hlp
|
|
Hierarchical flexgrid
|
flex
|
flexOrders
|
HScroll bar
|
hsb
|
hsbVolume
|
Image
|
img
|
imgIcon
|
Image combo
|
imgcbo
|
imgcboProduct
|
ImageList
|
ils
|
ilsAllIcons
|
Label
|
lbl
|
lblHelpMessage
|
Line
|
lin
|
linVertical
|
LinkLabel
|
lnk
|
|
List box
|
lst
|
lstPolicyCodes
|
ListView
|
lvw
|
lvwHeadings
|
MAPI message
|
mpm
|
mpmSentMessage
|
MAPI session
|
mps
|
mpsSession
|
MCI
|
mci
|
mciVideo
|
Menu
|
mnu
|
mnuFileOpen
|
Month view
|
mvw
|
mvwPeriod
|
MonthCalendar
|
mcl
|
|
MS Chart
|
ch
|
chSalesbyRegion
|
MS Flex grid
|
msg
|
msgClients
|
MS Tab
|
mst
|
mstFirst
|
NotifyIcon
|
nti
|
|
NumericUpDown
|
nupd
|
|
OLE container
|
ole
|
oleWorksheet
|
OpenFileDialog
|
ofdlg
|
|
PageSetUpDialog
|
psdlg
|
|
Picture box
|
pic
|
picVGA
|
Picture clip
|
clp
|
clpToolbar
|
PrintDocument
|
prndoc
|
|
PrintPreviewControl
|
ppctl
|
|
PrintPreviewDialog
|
ppdlg
|
|
ProgressBar
|
prg
|
prgLoadFile
|
RadioButton
|
rbtn
|
|
Remote Data
|
rd
|
rdTitles
|
RichTextBox
|
rtf
|
rtfReport
|
SaveFileDialog
|
sfdlg
|
|
Shape
|
shp
|
shpCircle
|
Slider
|
sld
|
sldScale
|
Spin
|
spn
|
spnPages
|
Splitter
|
spt
|
|
StatusBar
|
sta
|
staDateTime
|
SysInfo
|
sys
|
sysMonitor
|
TabContrl
|
tab
|
|
TabStrip
|
tab
|
tabOptions
|
Text box
|
txt
|
txtLastName
|
Timer
|
tmr
|
tmrAlarm
|
Toolbar
|
tlb
|
tlbActions
|
TrackBar
|
trb
|
|
TreeView
|
tre
|
treOrganization
|
UpDown
|
upd
|
updDirection
|
VScroll bar
|
vsb
|
vsbRate
|
1 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
|
数据类型
|
数据类型简写
|
标准命名举例
|
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
|
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
|