1

用Pascal规则:

第一个字母必须大写,必须后面的连接词的第一个字母均为大写。

例如:

void DataGrid
   2: {
   3:     
   4: }
2

用Camel规则;

名称中第一个单词的第一个字母为小写,其他单词的第一个字符为大写。

例如:

string strUserName;
3

所有的成员变量前加前缀“_”:

例如:

class DataBase
   2: {
string _nameString;
   4: }
4

接口的名称加前缀“I”:

例如:

class Iconvertible
   2: {
   3:     
   4: }
5

方法的命名,一般将命名为动宾短语:

例如:

class File
   2: {
string filePath)
   4:     {
   5:  
   6:     }
   7: }
6

所有的成员变量申明在类的顶端。

public calss Student
   2: {
string _name;
string _sex;
int _age;
   6:     
void ReadBook()
   8:     {
   9:     }
  10: }
7

使用某个控件的值时,尽量命名局部变量:

string GetTile()
   2: {
string title = lab_Title.Text;
return title;
   5: }

相关文章: