Potential calculation erros in Double.TryParse and Double.Parse with Invariant culture and NumberStyles.Any
AlexanderSemenyak opened this issue · comments
Issue (example):
Double.Parse("77,65", System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture)
return 7765
Cause: System.Globalization.NumberStyles.AllowThousands
https://stackoverflow.com/questions/46109025/c-sharp-double-tryparse-with-invariantculture-returns-unexpected-result
Sample for fix:
use Public Shared NumberStyleAnyWithoutAllowThousands as NumberStyles = NumberStyles.Any - NumberStyles.AllowThousands
instead NumberStyles.Any
Thanks @AlexanderSemenyak for the valuable tip. Maybe this will do the trick? ef026a9
Thank's :)
But also great idea - replace all Double.Parse (TryParse) for other code by this extensions methods from General.vb