zoukankan      html  css  js  c++  java
  • C#学习笔记——命名规范

    1

    用Pascal规则:

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

    例如:

       1: public void DataGrid
       2: {
       3:     
       4: }
    2

    用Camel规则;

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

    例如:

       1: string strUserName;
    3

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

    例如:

       1: public class DataBase
       2: {
       3:     private string _nameString;
       4: }
    4

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

    例如:

       1: public class Iconvertible
       2: {
       3:     
       4: }
    5

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

    例如:

       1: public class File
       2: {
       3:     public void CreateFile(string filePath)
       4:     {
       5:  
       6:     }
       7: }
    6

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

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

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

       1: public string GetTile()
       2: {
       3:     string title = lab_Title.Text;
       4:     return title;
       5: }
  • 相关阅读:
    day14(JavaDoc)
    day15(Java流程控制)
    day12
    day.6
    day10
    day11(运算符)
    day.5
    proc -x cshell fork()
    I/O -x 标准IO fopen-fclose--fgetc-fputc--fgets-fputs--fwrite-fread--fprintf-fscanf
    I/O -x open()-read()-write()-close()-lseek()
  • 原文地址:https://www.cnblogs.com/hanzhaoxin/p/2815417.html
Copyright © 2011-2022 走看看