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