Reading notes---157 tips for improving C # programming

Source: Internet
Author: User

1. When splicing a string, if other types are involved, the first ToString will reduce the boxing operation, and if the string variable is frequently manipulated, the use of StringBuilder is more efficient.

2.tryParse high efficiency relative to parse, TryParse failed to return 0

3.as is not prone to throwing exceptions relative to casts (that is, ()), or null if the source object is null

4.int? When converting to int type, is available?? operator, if the source object is null returns 0

The difference between 5.readonly and Const is that ReadOnly is a running constant, const is a compile-time, and ReadOnly is more flexible than a const can only modify primitive types, enumerations, and string types; const cannot be modified by static. Because it's natural that it's static.

6. Use the 0 value as the default value for the enumeration

Reading notes---157 tips for improving C # programming

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.