. Net (C #) Code Performance Optimization _ ax

Source: Internet
Author: User

① String AX = string. empty;
Note: Do not use: String AX = ""; I don't konw why. But it's Microsoft's convention.
Determine whether ax is null:
Ax. Length = 0> AX = string. Empty
info: "To test for empty strings, check if string. length is
equal to zero. constructs such "". equals (somestring)
and string. empty. equals (somestring) are less efficient
than testing the string length. replace these with
checks for somestring. length = 0. "

2007-7-13 13:51:10
② Catch {} Should catch detailed exceptions and do not throw them.
Catch the specific exception than "system. Exception" or rethrow the exception.
Catching generic exception types can hide run-time problems from the library user,
And can complicate debugging.

③ Do not use. tolower ()/. toupper () when comparing strings ()
Replace by equals ()
Don't create a string never used later.
[To be continued]

Blog garden → axe to help Shao Zhu

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.