1. Use Pascal to define the type, method name, and constant
Public class SomeClass
{Const int DefaultSize = 100; public SomeMethod () ;{}} 2. Use the camel name method int number for the local variable name and method parameters; void MyMethod (int someNumber ){}
3. Add I interface IMyInterface {…} to the interface Name {...} 4. Add m _ before the private member variable _. For variable names after m _, use the camel naming method public class SomeClass {private int m_Number ;}
5. add the suffix attribute6to the custom attribute class. Add the suffix exception7to the custom exception class. Use the verb-object pair for the method name, such as ShowDialog () 8. the names of methods with returned values must contain descriptions of returned values, such as GetObjectState () 9. use descriptive variable name a) to avoid single-character variable names, such as I or t. Use meaningful names like index or temp. B) do not use Hungarian notation c for public or protected variables. Do not use abbreviations for words (for example, replace number with num)
10. Always use the C # pre-defined type instead of the alias in the System namespace. For example, use object instead of Object to use string instead of String to use int instead of Int32.
11. When using generics, the first letter of the type should be capitalized. When the Type in. NET is processed, the Type suffix is retained. (C #2.0 new features) // correct public class category list {...} // Avoid public class upload list {...} 12. use a meaningful name to define a namespace, such as product name or company name 13. avoid using the type name in a fully qualified manner and use the using Keyword 14. avoid using the using Keyword 15 in a namespace. organize all the namespaces provided by the system framework, and place the names provided by third parties under the system namespace
Using system;
Using System. Collection. Generic; using System. ComponentModel; using System. Data; using MyCompany; using MyControls;
16. Use proxy derivation instead of explicitly instantiating a proxy (C #2.0 new feature) delegate void SomeDelegate (); public void SomeMethod ();{...}
17. Maintain strict code indentation. Do not use tabs or non-standard indentation, such as a space. The recommended indentation is 3 to 4 spaces 18. Add comments to this line of code at the same level as your code indent 19. All comments should be checked by spelling. Misspelling in the comment indicates that the development progress is delayed. 20. all class member variables should be declared at the top of the class, and a blank line should be used to separate them from the declaration of method and attribute. public class MyClass {int m_Number; string m_Name; public void SomeMethod1 (); public void SomeMethod2 ();}
21. declare the local variable 22 to the nearest place where a local variable is used. A file name should reflect its corresponding class name 23. when a partial classification is used and the class is distributed to different files, the file implementation part is added at the end of each file name to play a role in the class as a whole. Example: // In MyClas. cs public partical class MyClass {...} // In MyClass. Designer. cs public partical class MyClass {...} 24. Always put the curly braces "{" in the new line.
1. Use Pascal to define the type, method name, and constant
Public class SomeClass
{Const int defaultsize = 100; Public somemethod () ;{}} 2. Use the camel name method int number for the local variable name and method parameters; void mymethod (INT somenumber ){}
3. Add I interface imyinterface {…} to the interface Name {...} 4. Add M _ before the private member variable _. For variable names after M _, use the camel naming method public class someclass {private int m_number ;}
5. add the suffix attribute6to the custom attribute class. Add the suffix exception7to the custom exception class. Use the verb-object pair for the method name, such as showdialog () 8. the names of methods with returned values must contain descriptions of returned values, such as getobjectstate () 9. use descriptive variable name a) to avoid single-character variable names, such as I or T. Use meaningful names like index or temp. B) do not use Hungarian notation C for public or protected variables. Do not use abbreviations for words (for example, replace number with num)
10. Always use the C # pre-defined type instead of the alias in the System namespace. For example, use object instead of Object to use string instead of String to use int instead of Int32.
11. When using generics, the first letter of the type should be capitalized. When the Type in. NET is processed, the Type suffix is retained. (C #2.0 new features) // correct public class category list {...} // Avoid public class upload list {...} 12. use a meaningful name to define a namespace, such as product name or company name 13. avoid using the type name in a fully qualified manner and use the using Keyword 14. avoid using the using Keyword 15 in a namespace. organize all the namespaces provided by the system framework, and place the names provided by third parties under the system namespace
Using system;
Using System. Collection. Generic; using System. ComponentModel; using System. Data; using MyCompany; using MyControls;
16. Use proxy derivation instead of explicitly instantiating a proxy (C #2.0 new feature) delegate void SomeDelegate (); public void SomeMethod ();{...}
17. Maintain strict code indentation. Do not use tabs or non-standard indentation, such as a space. The recommended indentation is 3 to 4 spaces 18. Add comments to this line of code at the same level as your code indent 19. All comments should be checked by spelling. Misspelling in the comment indicates that the development progress is delayed. 20. all class member variables should be declared at the top of the class, and a blank line should be used to separate them from the declaration of method and attribute. Public class myclass {int m_number; string m_name; public void somemethod1 (); Public void somemethod2 ();}
21. declare the local variable 22 to the nearest place where a local variable is used. A file name should reflect its corresponding class name 23. when a partial classification is used and the class is distributed to different files, the file implementation part is added at the end of each file name to play a role in the class as a whole. Example: // In myclas. CS public partical class myclass {...} // In myclass. Designer. CS public partical class myclass {...} 24. Always put the curly braces "{" in the new line.