If you are using C # 3.0 or higher, you can use extension methods .
public static string RemoveNonNumeric(this string s) { return s.Replace("$", ""); }
Then your code could be changed to:
((String)dr[columnName]).RemoveNonNumeric();
This will allow you to subsequently change the implementation of RemoveNonNumeric to remove things like commas or $ signs in foreign currency, etc.
Also, if the object exiting the database is indeed a string, you should not call ToString (), since the object is already a string. You can drop it instead.
source share