views:

402

answers:

1

I created a CultureInfo object using new CultureInfo("fr-FR"). Now I have a number that I want to call .ToString("C", FrenchCultureInfo). The resulting string puts the € AFTER the number. Why?

CultureInfo french = new CultureInfo("fr-FR");
double value = 1234.56;
string output = value.ToString("C", french);//output = "1 234,56 €"

From all I've seen, the Euro needs to be on the left, and my business requirements mandate that it is on the left. However, there is no way to programmatically set this value.

Any ideas on how I can set this value easily? I have started to take a US culture object and copy everything from the French culture over to it, since we still want all the other French settings, except for the Euro on the right value. But this method is very time consuming and frustrating.

Thanks!

A: 

Clone the original and then modify it:

CultureInfo french = new CultureInfo("fr-FR");
french = (CultureInfo) french.Clone();
// Adjust these to suit
french.NumberFormat.CurrencyPositivePattern = 2;
french.NumberFormat.CurrencyNegativePattern = 2;
double value = 1234.56;
string output = value.ToString("C", french);//output = "€ 1 234,56"

Note that this will only affect that specific CultureInfo object, not the one obtained for French in general - so you'll need to make sure you use it everywhere.

Jon Skeet
Man, the one property I DIDN'T check. Thanks Jon!
Eric Lynes