Convert any currency string to double
You should pass NumberStyles to the Parse function
Decimal.Parse("$20,000.00", NumberStyles.AllowCurrencySymbol | NumberStyles.AllowDecimalPoint | NumberStyles.AllowThousands, new CultureInfo("en-US"));
A few other things, for currencies I would suggest you use Decimal. And this might be way off, but it might be better to store the currency data as Money in the DB and add a currency code to identify the currency of the value.
Yes, and the answers suggestung NumberStyles.Currency that would be better. It is a pre-Or'd value, if you still think you want to use the strings.
I think this should work:
double.Parse(currencyValue, NumberStyles.Currency);
Here you can see more about the NumberStyles.
Edit: In case anyone sees this answer without looking at the other answers/comments, this answer answered the question as written, but storing currency as a double
is not a good idea, and it would be better to use decimal instead.
You can also use the tryparse()
string input = "$2,000.00";
double parsed = 0d;
double.TryParse(input, NumberStyles.AllowCurrencySymbol | NumberStyles.AllowDecimalPoint | NumberStyles.AllowThousands, CultureInfo.CurrentCulture, out parsed))