Often people say it's better to say s.Length == 0 instead of s == "" . But it looks like it will be microoptimization, which also makes reading difficult. In addition, ten million of the former, unlike the latter, retain 60 ms at best.
Is there a reason why I am absent, for example, if perhaps s.Length == 0 really conveys the intention better? Or is it often necessary to compare many lines for emptiness?
EDIT: I know about IsNullOrEmpty, but when people answer a question, they often mention that checking for length is better than comparing with an empty string.
EDIT2: Donβt ask how best to do this, what will be IsNullOrEmpty for both cases, but I ask why this small minority insists that checking the length is superior. I assume that they have good reason to talk about it, and they want to know what they are.
EDIT3: As said at the beginning, I know that one is faster than the other. The question is why do people recommend this? Some timings showed that this did not lead to significant differences.
Jamie source share