20151009 C # First program writing specification

Source: Internet
Author: User

20151009

Program Writing specification

1. Code writing Rules:

1), use the interface as much as possible, and then implement the interface using the class.

2), key statement write comments

3), avoid writing more than 5 parameters of the method, if you want to pass multiple parameters, use the structure

4), avoid the code size of the try... catch ... Module

5), avoid placing multiple classes in the same file

6),switch statement must have the default statement to handle the unexpected situation

7), build and build a long string, be sure to use the StringBuilder type (variable character sequence) instead of using string

8),if statement should be included with {} .

2. Naming specification

1), using Pascal rules to name methods and types

Pascal rule: The first letter is capitalized, and the first letter of the subsequent join word is also capitalized

Such as:

public class DataGrid

{

public void DataBind

{

...

}

}

2), using the Camel rules to name the parameters of local variables and methods

Pascal rule: First letter lowercase for first word

Such as:

String strUserName

public void AddUser (String strUserID, byte[] bypassword);

3), all member variables preceded by the prefix "_"

For example, declaring a private member variable in a public class DataBase

public class DataBase

{

Private string _connectionstring;

}

4), the name of the interface plus "I"

Such as: Create a public interface iconvertible

public interface IConvertible

{

Byte ToByte ();

}

5), the name of the method, it is generally named as the verb-bin phrase

For example: create CreateFile and GetPath methods in public class File

public class File

{

public void CreateFile (String strFilePath)

{

...

}

public void GetPath (string path)

{

...

}

}

6), all member variables declared at the top of the class

Such as:

public class Product

{

Private string _productid;

Private string _productname

public void Addproduct (string strproductid, String strproductname)

{

...

}

}

7), naming namespaces with meaningful names, such as company name, product name

Such as:

Namespace Zivsoft// company name

{

...

}

Namespace ERP// product naming
{

...

}

8), when using a control value, try to name the local variable

Such as:

public string GetTitle ()

{

String title = Lbl_title.text;

Return title;

}

20151009 C # First program writing specification

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.