日期:2014-05-17  浏览次数:21054 次

ASP.net/C#编码规范

ASP.net/C#编码规范
2010年06月03日
  以下对本节使用的名词进行说明。 Pascal 所有单词第一个字母大写,其他字母小写。
  例如:public void GetUserNameByGuid() Camel 除了第一个单词,所有单词第一个字母大写,其他字母小写。
  例如:string userName Hungarian 对象类型(小写)+功能名称(大写,可以无此段)+操作对象(大写)。
  例如: 命名规范的具体要求详见表。 项 编码形式 相关例子 注释 文件 Pascal DatabaseConnector 使用名词来描述类 类 Pascal DatabaseConnector 类的名称应该与定义它们的文件的名称匹配 接口 Pascal IDatabaseConnector 接口名称以一个字母I开头 方法 Pascal CalculateBalance 使用动词来描述方法 私有和受保护的实例字段 camel private float accountBalance   公共实例字段 Pascal CustomerName   私有和受保护的类字段 camel protected static int numberOfAccounts   公共类字段 Pascal public static bool HasGoodCredit   static final 全部大写 public static final decimal MINNUMBALANCE = 100   局部变量 camel string accountNumber = FindAccountByCustomerName(customerName)   循环计数 全部小写 int i =0; while(i  对象类型名缩写见控件匈牙利命名缩写表 命名空间 Pascal namespace DataLayer   单元测试方法 Pascal TestFindAllCustomers 单元测试名称以单词Test开头。 解决方案 Pascal NorthWindTrader   项目 Pascal DataLayer   控件匈牙利命名缩写表。 标准控件 Button btn     CheckBox chk     CheckedListBox ckl     ComboBox cmb     DateTimePicker dtp     Label lbl     LinkLabel llb     ListBox lst     ListView lvw     MaskedTextBox mtx     MonthCalendar cdr     NotifyIcon icn     NumeircUpDown nud     PictureBox pic     ProgressBar prg     RadioButton rdo     RichTextBox rtx     TextBox txt     ToolTip tip     TreeView tvw     WebBrowser wbs     容器控件 FlowLayoutPanel flp     GroupBox grp     Panel pnl     SplitContainer spl     TabControl tab     TableLayoutPanel tlp     菜单和工具栏 ContextMenuStrip cms     MenuStrip mns     StatusStrip ssr     ToolStrip tsr     ToolStripContainer tsc     数据 DataSet dts     DataGridView dgv     BindingSource bds     BindingNavigator bdn     ReportViewer rpv     Repeater rpt 对话框 ColorDialog cld     FolderBrowserDialog fbd     FontDialog fnd     OpenFileDialog ofd     SaveFileDialog sfd     组件 BackgroundWorker bgw     DirectoryEntry dre     DirectorySearcher drs     ErrorProvider err     EventLog evl     FileSystemWatcher fsw     HelpProvider hlp     ImageList img     MessageQueue msq     PerformanceCounter pfc Process prc SerialPort spt ServiceController scl Timer tmr 印刷 PageSetupDialog psd     PrintDialog prd     PrintDocument pdc     PrintPreviewControl prv     PrintPreviewDialog ppd     水晶报表 CrystalReportViewer crv     ReportDocument rpd     其他 DomainUpDown dud     HScrollBar hsc     PropertyGrid prg     Splitter spl     TrackBar trb     VScrollBar vsc     1、函数、属性、类等注释
  请使用///三斜线注释,这种注释是基于XML的,不仅能导出XML制作帮助文档,而且在各个函数、属性、类等的使用中,编辑环境会自动带出注释,方便你的开发。以protected,protected Internal,public声明的定义注释请都以这样命名方法。 类型 相关例子 说明 文档注释 ///