Best practices in developing ASP.NET applications





5.00/5 (4 votes)
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 }