Question

In .net VB have a multi-lingual and multi-currency price listing that comes from two sources. For prices coming from our SQL server where prices are held as a Money datatype, all is well if we change languages. i.e. US$599.00 in English is displayed as US$599,00 in Italian.

Currency and price are separate fields, btw.

However, when the data source is from our partners web service when the data is a string, then US$599.00 is still correct in English but when in Italian, Spanish or German it is US$599.00,00. I can't work out what's going wrong with it. Not all prices are full units so I can't just parse an integer.

Any advice would be appreciated.

Était-ce utile?

La solution

The string from the web service is "599.00". If I Convert.ToDecimal(theString) I still get 599.00,00 when displayed in the datagrid output.

If the string from the web service always uses a dot as decimal separator, convert using the InvariantCulture, which has a . as DecimalSeparator:

decimal amount = Convert.ToDecimal("559.00", CultureInfo.InvariantCulture);
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top