1

I have a number stored in the database as a float. In this case the number is 93.75

double localCultreResult;
double.TryParse(rs["CostClaim"].ToString(), System.Globalization.NumberStyles.Any, CultureInfo.CurrentCulture, out localCultreResult);
if (rs["CostClaim"].ToString().Length > 0) {
    Cost.Value = localCultreResult;
};

I want the cost value to display as 93,75 when in French locale but instead the above gives me 9375,00

I have also tried all solutions here: How do I parse a string with a decimal point to a double?

All are converting 93.75 to 9375 when in French locale

1 Answers1

1

If CultureInfo.CurrentCulture is french then rs["CostClaim"].ToString() will be parsed with a ',' as decimal point.

What do you think of:

if (double.TryParse(rs["CostClaim"].ToString(), System.Globalization.NumberStyles.Any, 
    CultureInfo.GetCultureInfo("en-US"), out double localCultreResult))
{
    Cost.Value = localCultreResult;
}