Click here to Skip to main content
15,885,244 members
Articles / Web Development / ASP.NET
Alternative
Tip/Trick

Best practices in developing ASP.NET applications

Rate me:
Please Sign up or sign in to vote.
5.00/5 (4 votes)
3 Feb 2011CPOL 9.2K   5   2
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...
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)


Written By
Web Developer
Australia Australia
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
Questionif you are working an application, we always have somthing i... Pin
WebMaster8-Jan-13 4:12
WebMaster8-Jan-13 4:12 
Generalif you are working an application, we always have somthing i... Pin
Mahendra Vishwakarma4-Feb-11 5:11
Mahendra Vishwakarma4-Feb-11 5:11 

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.