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
 
Back
Top