I agree with Chris...
string.IsNullOrEmpty: 312 ms
Length: 140 ms [fastest]
This is not a fair comparison.
Need to compare:
(string != null && string.Length !=0)
with:
String.IsNullOrEmpty(string)
Even if the first construct is faster, there is a readability factor:
if (!String.IsNullOrEmpty(someString)) {
...
}
or:
if (someString != null && someString.Length != 0) {
...
}
The second construct becomes increasingly ugly if there is more than one
string
to deal with.