文件名称:C# 代码编写规范
文件大小:243KB
文件格式:PDF
更新时间:2016-06-18 04:15:51
C# 代码编写规范
C# 代码编写规范 目录 目录1目的..............................................................................................................................................2 1目的.......................................................................................................................................................4 2适应范围...............................................................................................................................................4 3术语及缩略语.......................................................................................................................................4 4规范内容...............................................................................................................................................4 4.1命名总体规则................................................................................................................................4 4.2命名规范........................................................................................................................................5 4.2.1变量命名.................................................................................................................................5 4.2.2常量命名.................................................................................................................................7 4.2.3类(Class)命名.........................................................................................................................7 4.2.4接口(Interface)命名................................................................................................................7 4.2.5方法(Method)命名..................................................................................................................8 4.2.6命名空间(NameSpace)命名...................................................................................................8 4.2.7属性(Property)命名................................................................................................................8 4.3注释规范........................................................................................................................................8 4.3.1概述.........................................................................................................................................8 4.3.2自建代码文件注释.................................................................................................................9 4.3.3模块(类)注释..........................................................................................................................9 4.3.4类属性注释...........................................................................................................................10 4.3.5方法注释...............................................................................................................................10 4.3.6代码间注释........................................................................................................................... 11 4.4编码规则...................................................................................................................................... 11 4.4.1错误检查规则....................................................................................................................... 11 4.4.2大括号规则........................................................................................................................... 11 4.4.3小括号规则........................................................................................................................... 11 4.4.4缩进规则...............................................................................................................................12 4.4.5对齐规则...............................................................................................................................12 4.4.6比较规则...............................................................................................................................12 4.4.7 Case规则..............................................................................................................................12 4.4.8 If … Else规则.......................................................................................................................12 4.4.9单语句规则...........................................................................................................................13 4.4.10单一功能准则.....................................................................................................................13 4.4.11简单功能准则.....................................................................................................................13 4.4.12明确条件规则.....................................................................................................................13 4.4.13选用False规则..................................................................................................................13 4.4.14独立赋值规则.....................................................................................................................13 4.4.15定义常量规则.....................................................................................................................14 4.4.16模块化规则.........................................................................................................................14 4.4.17交流规则.............................................................................................................................14 4.5编程准则......................................................................................................................................14 4.5.1变量使用...............................................................................................................................14 4.5.2数据库操作...........................................................................................................................14 4.5.3对象使用...............................................................................................................................15 4.5.4模块设计原则.......................................................................................................................15 4.5.5结构化要求...........................................................................................................................15 4.5.6函数返回值原则...................................................................................................................16 4.6代码包规范..................................................................................................................................16 4.6.1代码包的版本号...................................................................................................................16 4.6.2代码包的标识.......................................................................................................................16 4.7代码控制......................................................................................................................................17 4.7.1代码库/目录的建立..............................................................................................................17 4.7.2代码归档...............................................................................................................................17 附件1:数据类型缩写表.................................................................................................................17 附件2:控件名缩写表.....................................................................................................................18 a、.NET控件................................................................................................................................18 b、html控件..................................................................................................................................19