ASP. NET Code compiling specifications that should be known to beginners, asp.net code
1. The name of a local variable must be meaningful. Use the corresponding English name, for example, the "user name" variable. Do not use aa bb cc or userName instead.
2. Do not use single-letter variables, such as I, n, and x. Instead, use index, temp, and so on. Variable exceptions used for loop iteration.
3. Use the Pascal naming method to name the method name, attribute name, class name, and namespace. Generally, the method is named as a dynamic object phrase, as shown in figure
◆ ShowDialog ();
◆ CreateFile ();
◆ GetPath ();
4. Use the Camel naming method to name parameters of local variables and methods.
The preceding examples are as follows:
Public class Neeke
{
Public Neeke ()
{
}
Private string neekeName;
Public string NeekeName
{
Get {return neekeName ;}
Set {neekeName = value ;}
}
Public void CallMe ()
{
System. Console. WriteLine ("Hello Neeke! ");
}
}
5. Only use the Hungarian naming method to name WinForm and Web spaces. Do not use textbox1, gridview1, or other default names.
6. The interface name should be prefixed with "Big and lowercase I", such as "INeeke", to distinguish interfaces and classes intuitively.
7. Use the hierarchical structure of the namespace to organize various types and interfaces.
Correct:
Using Www. Ineeke. Cn;
Namespace Ineeke. Cn
{
...
}
Error:
Using WwwIneekeCn;
Namespace IneekeCn
{
...
}
8. All codes must have sufficient comments. The comments must be over 15%. The content to be annotated includes the following.
1) key statements (such as key variable declaration and condition judgment ).
2) The document comment before the class name (comments starting with //) includes the simple function description and usage of the class.
3) methods with complex parameter lists.
9. Use the Tab key to indent the code. Do not use the space key.