C # code writing rules:
1. use the interface as much as possible, and then use the class to implement the interface to improve program flexibility.
2. Do not exceed 80 characters in one line
3. Try not to manually change the computer-generated code
4. Write comments on key statements
5. Suggest that local variables are declared at the nearest place to use it
6. Do not use Goto series statements unless you are using it when jumping out of a deep loop
7. Avoid a method that uses more than 5 parameters.
8. Avoid writing try....catch modules with too much code
9. Avoid placing multiple classes in the same file
10. When building and building a long string, be sure to use the StringBuilder type instead of the string type
11.switch statements must have a default statement to handle unexpected situations
12. For the IF statement, use "{}" to enclose the statement block
13. Try not to use the This keyword reference
C # Naming conventions:
1. Using the Pascal rule to name the method and the type, the Pascal naming rule is that the first letter must be capitalized, and the first letter of the following concatenated words should be capitalized.
Eg:public class DataGrid;
2. Use the camel rule to name the parameters of the local variables and methods, with the first letter lowercase in the name
Eg:string strUserName;
3. Prefix "_" for all member variables
Eg:public class DataBase
{
private string _connectionstring;
}
4. Interface name prefixed with "I"
Eg:public interface IConvertible
{
byte ToByte ();
}
5. All member variables are declared at the top of the class, separated by a newline .
Eg:private class Product
{
private string _productld;
private string _productname;
}
6. When using the value of a control, name the local variable as much as possible
Eg:public string GetTitle ()
{
string title = Lbl_title.text;
return title;
}
C # Naming conventions