Reputation: 3957
Our web application (.net/C#) formats currency amounts using amount.ToString("c"), shown localized to a few different regions.
Our French Candian users prefer all amounts to be the US format (123,456.99 vs. the default windows way for fr-CA of 123 456,99).
What is the best way to handle that ? Can I simply modify the regional settings on each webserver in windows for fr-ca? or do I need to create a custom culture?
Upvotes: 3
Views: 3379
Reputation: 158389
You may want to look into creating a custom culture, providing the mix of formatting rules that you requre. There is an article at MSDN describing how to do it.
In short, you create a CultureAndRegionInfoBuilder
object, define the name, set properties, and register it. Check the article for details.
Upvotes: 2
Reputation: 4657
You can modify the current culture like so:
Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-CA")
You could pull the value from web.config, sure.
EDIT:
Ok, sorry I misunderstood.
This might work:
decimal d = 1232343456.99M;
CultureInfo USFormat = new CultureInfo("en-US");
Console.Out.WriteLine(d.ToString(USFormat));
This should allow you to just use the USFormat when you're outputting numeric vals.
Upvotes: 1
Reputation: 7983
I would create a User Settings for the application, that would hold the CultureInfo for each user, and create a form to allow each user to edit the property ....
Upvotes: 0