Why would double.TryParse()
with these settings not parse
double.TryParse("1.035,00",
NumberStyles.AllowCurrencySymbol | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite |
NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign,
GlobalSettings.Instance.DefaultCulture, out price);
where DefaultCulture
is sl-SI (Slovenian), which has the dot .
as digit grouping symbol and , as decimal point. The price
remains 0
after the parse.
?
You are missing NumberStyles.AllowThousands
:
double.TryParse("1.035,00", NumberStyles.AllowCurrencySymbol |
NumberStyles.AllowLeadingWhite |
NumberStyles.AllowTrailingWhite |
NumberStyles.AllowDecimalPoint |
NumberStyles.AllowLeadingSign |
NumberStyles.AllowThousands,
GlobalSettings.Instance.DefaultCulture, out price);
This worked for me
double.TryParse("1.035,00",
NumberStyles.Any,
GlobalSettings.Instance.DefaultCulture, out price);
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