views:

244

answers:

1

I have a .NET application available in several different language. i basically load and save file (containing doubles) in the System Culture but i would like to force numbers to always be displayed and entered using the US culture format (comma as digit grouping, period as decimal separator). I tried to override the application Culture but it doesn't seem to work. Is there a way to deal with this?

A: 

CultureInfo.InvariantCulture exists for the specific purpose of persisting data in a consistent format. More Info on MSDN

For the UI, if you really want all formatting to be US-style, you can do this:

Application.CurrentCulture = new CultureInfo("en-US");

Note that you would need to set the culture on each thread.

dahlbyk
Would it break the UI if i set Application.CultureInfo = InvariantCulture?
zaladane
I guess I misunderstood you. The purpose of InvariantCulture would be to store the doubles in a culture-agnostic way; it should not be used for the UI. For that, I would set Application.CurrentCulture = new CultureInfo("en-US").
dahlbyk