50 points to improve C # programming level

Source: Internet
Author: User

The following article is reproduced in

50 points to improve C # programming level

1. Always use attributes to replace accessible data members

2. between readonly and const , priority is given to using readonly

3. Use the AS operator as a priority between as and coercion type conversions

4. Use the conditional attribute (Conditional Attributes) instead of the conditional compilation statement #if

5. Always overload the ToString method for a custom class

6. Distinguishing between 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 valid data

9. Understanding the relationship between referenceequals, Static equals, instance equals and comparison operator (= =)

10. Understanding the shortcomings of the GetHashCode approach

11. When writing loops, use foreach as a priority.

12. Initialize a variable when it is defined

13. Use static constructors to initialize static member variables

14. Using a constructor chain when using multiple constructors

15. Use using and try/finally to handle the release of resources

16. Try to avoid the generation of resource waste

17. Avoid packing (boxing) and unpacking (unboxing) as much as possible

18. Implementing the Dispose method of a class

19. Between interface and inheritance (inheritance), use interface First (interface)

20. Distinguishing between interfaces and overloads (Overrides)

21. Using a delegate (delegate) to implement a callback (callback)

22. Using events to define an external interface

23. Avoid returning references to members within a class

24. Using meta data to control programs

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. Use the new operator only if the base class joins a function that has the same name as the existing function in the derived class

30. Use Cls-compliant as much as possible

31. Try to write a short, simple function

32. Try to write relatively small assemblies (assembly)

33. Limiting the visibility of types (visibility)

34. Write a large-grained web API

35. When using events, prioritize inheriting base class events instead of recreating an event

36. Multi-use Framework runtime Debugging (Debug, TRACE, EventLog, etc.)

37. Using the. NET Standard configuration mechanism

38. Using and supporting the data binding capabilities of. NET in the class

39. Using the. NET authentication mechanism (Validation)

40. Choose the right set of classes (Collection) according to your needs

41. Using the DataSet in a custom structure

42. Using Attributes (Attributes)

43. Do not over-use reflections (Reflection)

44. Create a complete, application-specific exception

45. Consider as many exceptions as possible in the program and make the processing

46. Use Interop as little as possible

47. Try to use the security Code (safe codes)

48. Learn more, use external tools and resources

49. Preparing to use C # 2.0

50. Learning the ECMA standard

50 points to improve C # programming level

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.