50 points to improve C # programming level

Source: Internet
Author: User
Tags inheritance reflection visibility
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
26. Implement IComparable and IComparer interfaces for objects that need to be sorted
27. Avoid using the ICloneable interface
28. Avoid using type conversion operators
29. You need to use the new operator only if the base class has added a function with the same name as the existing function in the derived class
30. Use Cls-compliant as much as possible
31. Write short, simple functions as far as possible
32. Try to write smaller assemblies (assembly)
33. Qualified type visibility (visibility)
34. Write a large-grained web API
35. When using an event, precedence inherits the base class event rather than recreating an event
36. Run-Time debugging for multi-use framework (debug, TRACE, EventLog, etc.)
37. Configuration mechanism using the. NET Standard
38. Using and supporting. NET data binding functionality in a class (Binding)
39. Authentication mechanism using. NET (Validation)
40. Choose the Right Collection class (Collection) according to your needs
41. Using a DataSet in a custom structure
42. Using Attributes (Attributes)
43. Do not use excessive reflection (Reflection)
44. Create complete, application-specific exceptions
45. Consider the possible anomalies of the procedure as much as possible and deal with them
46. Use of Interop as little as possible
47. Use safe code as far as possible
48. Learn more, use external tools and resources
49. Preparing to use C # 2.0
50. Learning ECMA Standards
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.