Blog Stats
  • Posts - 36
  • Articles - 0
  • Comments - 11
  • Trackbacks - 23

 

Friday, November 07, 2003

C# Course

http://www.jaggersoft.com/csharp_course/

Some clean code...

Simple tip that's saved me some time:

//This will set the variable test to null:

string test = Convert.ToString(ConfigurationSettings.AppSettings["Missing.Value"]);

//This will throw an exception:
string test = ConfigurationSettings.AppSettings["Missing.Value"].ToString();





The problem with the second statement is that null doesn't have a .ToString() method.
Either situation can be handled, but most of the time it's a lot cleaner to check for a null than to raise the exception.

 

 

Copyright © Ramesh Arimilli