9 Types of specifications for C # language naming

Source: Internet
Author: User

Here are 9 specifications for C # language naming:

A) class

Rule 1-1 uses the Pascal rule to name the class name, which is capitalized on the first letter.

"Rule 1-2" uses a noun or noun phrase that can reflect class functionality to name a class.

"Rule 1-3" do not use specific meaning prefixes such as "I", "C", "_", and so on.

The "Rule 1-4" Custom exception class should end with exception.

The "rule 1-5" file name can reflect the contents of the class, preferably the same name as the class.

b) Class field

"Rule 2-1" uses the camel rule to name the class member variable, that is, the first word (or the abbreviated word) lowercase.

The "_" prefix is preceded by the "Rule 2-2" class field variable name.

"Rule 2-3" is strongly forbidden to add "m_" (This is the old VC naming rule) before ordinary variables.

C) method

The "Rule 3-1" method name is a Pascal rule and the first character is capitalized.

The "Rule 3-2" method name should use a verb or a verb phrase.

Access modifiers or functionally identical methods in the "rule 3-3" class should be put together, and the methods of public or implementation interfaces are in front.

D) attribute

"Rule 4-1" uses nouns to define attributes, and attributes use the Pascal rule, with the first character capitalized.

The rule 4-2 property and the corresponding field name are associated, and you can use the Refactor menu to build the property.

e) Parameters

The rule 5-1 parameter is named with the camel rule and the first character is lowercase.

"Rule 5-2" uses descriptive parameter names, and parameter names should be the most descriptive.

"Rule 5-3" do not prefix the parameter with the Hungarian type notation.

"Rule 5-4" checks the validity of all input parameters.

f) Constants

The "rule 6-1" read-only constant uses the Pascal naming convention, which is capitalized in the first letter.

The "rule 6-2" enumeration name is named by the Pascal rule, and the enumeration member essence is a constant, as in the naming convention.

The "rule 6-3" enumeration value is defined from small to large.

The "Rule 6-4" static field or property uses the Pascal rule, which is capitalized on the first character.

g) interface

The "rule 7-1" interface definition uses the Pascal rule and must start with the uppercase "I".

The "Rule 7-2" interface name should be meaningful, do not have the underscore "_" characters in the middle.

"Rule 7-3" if the class implements an interface, the name tries to be the same as the interface, just omit the "I" character.

h) Events

The "rule 8-1" delegate name uses the Pascal rule, which is capitalized in the first character.

Rule 8-2 defines the delegate for the event to use the EventHandler suffix and includes sender and e two parameters.

The parameter class to use for the "Rule 8-3" event, with the name EventArgs suffix.

i) C # language namespace

The "Rule 9-1" namespace name is in the Pascal rule with the first character capitalized.

The "Rule 9-2" namespace name tries to reflect the overall functionality provided by its content.

9 Types of specifications for C # language naming

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.