Reputation: 37480
I have a field that I display via:
String.Format({0:c},amount)
This produces the string "$28.28"
However, when I try to convert back to a decimal amount, I get an incorrect format exception:
amount = Decimal.Parse(amount.Text, NumberStyles.Currency)
I also tried it with NumberStyles.AllowCurrencySymbol with the same results. I verified that the value in amount.Text is "$28.28".
Am I missing something? Shouldn't these two operations use the same currency symbol and formats?
Upvotes: 0
Views: 3418
Reputation: 20640
Are these on different machines? The machines be be setup differently. The default formats are set in the control panel regional settings.
Upvotes: 0
Reputation: 108977
var amount = decimal.Parse("$28.28", NumberStyles.Currency);
works fine for me. Make sure your input string is what you think it is.
Upvotes: 2