culture converting

  • Thread starter Thread starter rodchar
  • Start date Start date
R

rodchar

hey all,

is there a way to change a number from a France culture to US without
changing the current thread.

decimal.Parse("xxx", toUSA format)

or something to this effect?

thanks,
rodchar
 
Hi Rodchar,

You can use the decimal.Parse and decimal.ToString methods to parse the
number as written in France and then format it for the English (US) culture.
As you can see below this is done using the CultureInfo class.

using System.Globalization;

....

string decimalToParse = "4 111,39"; // as written in France
decimal parsedDecimal = decimal.Parse(decimalToParse,
CultureInfo.GetCultureInfo("fr-FR"));
string decimalInEnUS = parsedDecimal.ToString("N",
CultureInfo.GetCultureInfo("en-US"));

HTH
 
thanks for the help,
rod.

Stanimir Stoyanov said:
Hi Rodchar,

You can use the decimal.Parse and decimal.ToString methods to parse the
number as written in France and then format it for the English (US) culture.
As you can see below this is done using the CultureInfo class.

using System.Globalization;

....

string decimalToParse = "4 111,39"; // as written in France
decimal parsedDecimal = decimal.Parse(decimalToParse,
CultureInfo.GetCultureInfo("fr-FR"));
string decimalInEnUS = parsedDecimal.ToString("N",
CultureInfo.GetCultureInfo("en-US"));

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top