Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Best practices in developing ASP.NET applications

0.00/5 (No votes)
19 Jan 2011 1  
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...

VB
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.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here