C # How to judge if the string is null (1/3)

Source: Internet
Author: User
Tags reflector

C # How to judge whether the string is null

From the analysis, we can see that using the length method to empty string determination has a great performance advantage, especially when a large number of strings are empty! Of course, you must first determine whether the string instance is a null reference!


1. Three Common empty string determination methods:

Length Method: bool isempty = (str. length = 0 );
Empty method: bool isempty = (str = string. empty );
General method: bool isempty = (str = "");


2. in-depth internal mechanism:

To explore the internal mechanisms of these three methods, we need to first look at how. net is implemented, that is, to look at the source code of. net! However, where can we find the source code? We also have three methods:
Rotor Method: A good choice is Microsoft's rotor, which is a source code sharing project of Microsoft.
Mono method: Another good choice, of course, is the real Open-Source Project mono!
Reflector method: The last choice is to use the anti-compiler. However, the restructured code is not necessarily the original appearance, but an approximate value ", you can consider using the reflector anti-compiler [1]. 1 2 3

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.