问题
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?
回答1:
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.
回答2:
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.
回答3:
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 ....
来源:https://stackoverflow.com/questions/1167331/how-to-change-default-culture-settings-in-a-net-web-application