50 points to improve C # programming level

Source: Internet
Author: User

1. Always use properties to replace accessible data members
2. Between readonly and const, priority is given to the use of ReadOnly
3. Use the AS operator as a priority between as and coercion type conversions
4. Use conditional attributes (Conditional Attributes) to replace conditional compilation statements #if
5. Always overload the ToString method for the custom class
6. Distinguishing value types and reference types
7. Use immutable value types (immutable Atomic value Types)
8. In the value type, make sure that 0 is a legitimate data
9. Understanding the relationship between referenceequals, Static equals, instance equals and comparison operators (= =)
10. Understanding the flaws of the GetHashCode method
11. Use foreach as a priority when writing loops.
12. Initialize the variable when it is defined
13. Use static constructors to initialize static member variables
14. Use a constructor chain when using multiple constructors
15. Use using and try/finally to handle the release of resources
16. Avoid resource waste as far as possible
17. Avoid the use of boxing (boxing) and unboxing (unboxing)
18. Implementation class of Dispose method
19. Between interface and inheritance (inheritance), the preferred interface (interface)
20. Distinguishing between interfaces and overloads (Overrides)
21. Use a delegate (delegate) to implement the callback (callback)
22. Use event to define external interface
23. Avoid returning references to members within a class
24. Use Meta data to control program
25. Prioritize the use of serializable (serilizable) types

1. Attribute   (property)   is always used in place of the accessible data member
2. Between   readonly  and  const , prioritize using   ReadOnly
3. The use of  as  operators
4 is preferred between  as  and   forced type conversions. Use conditional properties   (conditional  Attributes)   To replace conditional compilation statements   #if  
5. Always overload the custom class  ToString  method
6. Distinguish value type and reference type
7. Use Immutable value types ( Immutable atomic value types)
8. In a value type, make sure that 0 is a valid data
9. Understanding  referenceequals, static The relationship between the  Equals, instance Equals  and   comparison operators (= =)
10. Understanding the flaws of the  gethashcode method
11. When writing Loops , the use of  foreach is preferred.
12. Initializes the variable when it is defined
13. Initializes a static member variable with a static constructor
14. Use a constructor chain
15 when using more than one constructor. Uses and try/finally to handle the release of a resource
16. Try to avoid resource garbage
17. Avoid the use of boxing (boxing) and unboxing (unboxing)
18. Implement class  Dispose  method
19. Between interfaces and inheritance (inheritance), Precedence interface (interface)
20. Differentiate interfaces and overloads (Overrides)
21. Use a delegate (delegate) to implement a callback (callback)
22. Define an external interface with events (event)
23. Avoid returning references to members within a class
24. Use metadata to control program
25. Use Serializable (serilizable) types to share your documents and browse the world.

Technology Blog Weibo Entertainment Blog
Blog Park Sina Weibo Sina Blog
51CTO Blog Tencent Weibo NetEase Blog
Share to Subscribe to this Blog

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.