Best practices in developing ASP.NET applications





5.00/5 (1 vote)
I agree with Chris...string.IsNullOrEmpty: 312 msLength: 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...
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)) { //do something with someString ... }or:
if (someString != null && someString.Length != 0) { //do something with someString ... }The second construct becomes increasingly ugly if there is more than one
string
to deal with.