C # code specification

Source: Internet
Author: User
Tags xml attribute

C # code specification

1. Write comments on the above and make full use of the prompts of C #

2. Short-circuit writing. A large number of prerequisites can be pre-processed to make the code implementation logic clearer and effectively see the depth of code nesting.

3. Use the built-in Action Func Predicate delegate type
Do not introduce additional types to increase the burden
Http://www.cnblogs.com/akwwl? Http://www.bkjia.com/kf/ware/vc/ "target =" _ blank "class =" keylink "> templates/aOsv8nS1M7et7W72Na1o6zSsr/templates + DQo8aW1nIGFsdD0 =" here write picture description "src =" http://www.bkjia.com/uploads/allimg/151127/0429402554-2.png "title =" \ "/>

After modification:

4. The container should not be public directly. The container must operate with its own permissions. If there is a large amount of code, it is not conducive to maintenance. A bug occurs and it does not know where to operate.

5. Use var and C # without too much attention to types

6. The hanging event corresponds to a reduction event to avoid Memory leakage.
In Start + = event, you need to immediately write the corresponding OnDestroy ()-= event

7. Do not use quest for task words

8. variable naming rules
* For example, an event cannot end with an event, and a class cannot end with a class.

9. EventHandler if you are sure that no sender is required, you can use Action

10. uppercase letters of the public Method

11. If the method is GetXXX, the return value cannot be void, and the return value must exist.

12. In C ++, the byte type or uint type int type enumeration uses the C # Strong type enumeration.

Or if the parameter is a uint or int, use a strongly-typed enumeration.

Or if the field attribute is of the uint type, use the strong type enumeration.

Or the dictionary key.

13. xml Attribute = spaces are not required between left and right

14. C # In C ++/Unity adopts Pascal naming rules, and js/ts adopts camel naming rules.

The preceding is a camel naming rule and the following is a Pascal naming rule.
Html

16. In C #, it is easy to use reference types, which is different from the value types in C ++ STL. When passing parameters, there will be no copy performance damage.

17. Note that the spelling of words is incorrect.

 

Related Article

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.