C#命名规范

本文详细介绍了C#中变量、方法、常量、控件等命名规则,包括命名方式、首字母大写规则、缩写约定以及相关标签体系结构。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、变量(Variables)首个字母小写,随后如有单词,首个字母大写,如firstNumbe 临时变量名的命名规则:i、j、k、m、n用于数字型变量,c、d、e用于字符型变量
2、方法名(Methods)方法名应该是动词,如果超过两个单词,则每个单词首个字母大写,如GetBackground()
3、常量(Constants)名称全部使用大写字母,两个单词之间用下划线连接,如ARRAY_SIZE
4、c#控件命名缩写

Button btn
Calender cld
CheckBox chk
CheckBoxList chklst
CompareValidator cv
DataGrid dg
DataList dl
DropDownList ddl
Image img
ImageButton imgbtn
Label lbl
LinkButton lnkbtn
ListBox lstb
Panel pnl
RadioButton rdo
RadioButtonList rdolist
RangeValidator rv
RegularExpressionValidator rev
RequiredFieldValidator rfv
Table tbl
TextBox txt
ValidatorSummary vs
ColorDialog clordlg
FolderBrowerDialog fbdlg
FontDialog fntdlg
SplitContainer sc
LinkLabel lnklbl
GroupBox grp
HelpProvider hlp
ListView lstv
OpenFileDialog ofiledlg
PageSetupDialog psdlg
PictureBox pic
PrintDialog pntdlg
PrintDocument pntdmt
PrintPreviewControl pntpvctrl
PrintPreviewDialog pntpvdlg
ProgressBar pgb
SaveFileDialog sfiledlg
StatusStrip stus
StripMenu mnu
TabControl tabctrl
Timer timer
ToolTip ttp
TreeView trev
Form frm
ComboBox cbb
DateGridView dgv
DateTimePicker dtp
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值