The input string in textbox is, say, $10.00 . I call
decimal result;
var a = decimal.TryParse(text, NumberStyles.AllowCurrencySymbol, cultureInfo, out result);
cultureInfo
is known (en-US
). Why does decimal.tryParse
returns false?
Thank you.
The problem is you've allowed the currency symbol itself, but you've omitted other properties that are required to parse it correctly (decimal point, for example.) What you really want is NumberStyles.Currency
:
decimal.TryParse("$10.00", NumberStyles.Currency, cultureInfo, out result);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With