1. Use Pascal rules to name methods and types.
Public class DataGrid <br/>{< br/> Public void databind () <br/>{</P> <p >}< br/>
2. Use camel rules to name parameters of local variables and methods.
Public class product <br/>{< br/> private string _ productid; <br/> private string _ productname; </P> <p> Public void addproduct (string productid, string productname) <br/>{</P> <p >}< br/>
3. prefix "_" before all member variables.
Public class database <br/>{< br/> private string _ connectionstring; <br/>}
4. The interface name is prefixed with "I ".
Public interface iconvertible <br/>{< br/> byte tobyte (); <br/>}
5. Custom Attributes end with "attribute.
Public class tableattribute: attribute <br/>{</P> <p >}< br/>
6. Custom exceptions end with exceptions.
Public class nullemptyexception: exception <br/>{</P> <p >}< br/>
7. Name the method. It is generally named as a verb-object phrase.
Public class file <br/>{< br/> Public void createfile (string filepath) <br/>{</P> <p >}< br/> Public void getpath (string path) <br/>{</P> <p >}< br/>
8. The local variable name must be meaningful.
Do not use X, Y, Z, and so on. I, J, K, L, M, and N can be used in for loop variables.
Public class user <br/>{< br/> Public void getuser () <br/>{< br/> string [] userids = {"Ziv", "zorywa ", "zlh" };</P> <p> for (INT I = 0, K = userids. length; I <K; I ++) <br/>{</P> <p >}< br/>
9. All member variables are declared at the top of the class and separated from the method by a line break.
Public class product <br/>{< br/> private string _ productid; <br/> private string _ productname; </P> <p> Public void addproduct (string productid, string productname) <br/>{</P> <p >}< br/>
10. Name namespace with meaningful names, such as the company name and product name.
Namespace zivsoft // company name <br/>{</P> <p >}< br/> namespace ERP // product name <br/>{</P> <p >}< br/>
11. We recommend that you declare a local variable when it is closest to using it.
12. Use the value of a control to name local variables whenever possible.
Public String gettitle () <br/>{< br/> String title = lbl_title.text; <br/> return title; <br/>}
14. Separate the referenced system namespace from the custom or third-party namespace with a line feed.
Using system; <br/> using system. web. ui; <br/> using system. windows. forms; </P> <p> using csharpcode; <br/> using csharpcode. style; <br/>
15. The file name should reflect the content of the class, preferably with the same name as the class. A class or a group of connected classes in a file.
16. The directory structure should reflect the namespace level.
17. The braces "{" need a new line.
Public sample () <br/> {<br/> // todo: add the constructor logic here <br/> // <br/>}
This article is from the csdn blog, reprinted please indicate the source: http://blog.csdn.net/skyaspnet/archive/2009/02/05/3865132.aspx