When A String Isn't Good Enough

Today I found this code in our code base:

string value = ConfigurationManager.AppSettings["AConfigurationValue"].ToString();

I guess getting a string back (which is what the indexer returns) isn't good enough - we need to call ToString() on a string to get the right string.


I wonder if there's an FxCop rule to warn you if you're calling ToString() on a string...

* Posted at 08.22.2007 09:19:02 AM CST | Link *

Blog History