Click here to Skip to main content
13,894,730 members
Click here to Skip to main content
Add your own
alternative version

Tagged as


3 bookmarked
Posted 19 Jan 2011
Licenced CPOL

Best practices in developing ASP.NET applications

, 19 Jan 2011
Rate this:
Please Sign up or sign in to 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)


Even if the first construct is faster, there is a readability factor:

if (!String.IsNullOrEmpty(someString)) {
//do something with someString

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.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Web Developer
Australia Australia
No Biography provided

You may also be interested in...


Comments and Discussions

General@Deeksha Shenoy: The best practice is whenever your are usin... Pin
Mahendra Vishwakarma30-Jan-11 20:45
memberMahendra Vishwakarma30-Jan-11 20:45 
@Deeksha Shenoy: The best practice is whenever your are using string variable, you have to initialize it with empty someString="";
GeneralHi, As u said string.IsNullOrEmpty is taking 312 ms. I real... Pin
sendtodilip24-Jan-11 18:42
professionalsendtodilip24-Jan-11 18:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web05 | 2.8.190306.1 | Last Updated 19 Jan 2011
Article Copyright 2011 by _impostor_
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid