Click here to Skip to main content
Click here to Skip to main content

Best practices in developing ASP.NET applications

By , 3 Feb 2011
 
Initializing is great... unless you have no control over the contents.
 
Consider this:
 
String strTmp = String.Empty;
strTmp = SomeRandomMethod();
//Suppose SomeRandomMethod returns null under some circumstances...
Now anything you try to do with strTmp (other than compare to null) will cause an exception - inlcuding the original tip:
if (strTmp.Length == 0) {
//etc
}

License

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

About the Author

_impostor_
Web Developer
Australia Australia
Member
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
Questionif you are working an application, we always have somthing i...memberdad42448 Jan '13 - 4:12 
if you are working an application, we always have somthing in mind for readability and performance both so if you are in a sitution like you want choose one in that then I think you have to go with performance not with readability factor...
 
//if you are using this and facing performance issues,please do not use it just for readability factor.
if (!String.IsNullOrEmpty(someString)) {//do something with someString...}or:

Generalif you are working an application, we always have somthing i...memberMahendra Vishwakarma4 Feb '11 - 5:11 
if you are working an application, we always have somthing in mind for readability and performance both so if you are in a sitution like you want choose one in that then I think you have to go with performance not with readability factor...
 
//if you are using this and facing performance issues,please do not use it just for readability factor.
if (!String.IsNullOrEmpty(someString)) {//do something with someString...}or:

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

Permalink | Advertise | Privacy | Mobile
Web02 | 2.6.130523.1 | Last Updated 3 Feb 2011
Article Copyright 2011 by _impostor_
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid