tags:

views:

52

answers:

4

Hello i use this

 CultureInfo culture = new CultureInfo("en-US");

        culture.DateTimeFormat.DateSeparator = "/";
        culture.DateTimeFormat.ShortDatePattern = "dd/MM/yyyy";

        //dekadikoi arithmoi
        culture.NumberFormat.NumberDecimalSeparator = ".";
        Thread.CurrentThread.CurrentCulture = culture;
        Thread.CurrentThread.CurrentUICulture = culture;

As it is required to work that way everywhere! The problem is that doing new CultureInfo("en-US"); all other computer-specific settings are omited... Is there a way to copy the CurrentCulture? I tried to modify currentculture but i got read only error...

+1  A: 

what about this : CultureInfo culture=CultureInfo.CurrentCulture;

Pramodh
+2  A: 

Just change one line:

CultureInfo culture = CultureInfo.GetCultureInfo("en-US");
Aliostad
+1  A: 

Just take a copy of the CurrentCulture class and modifiy it as you see fit. If you do need to change the CultureInfo of the thread itself (rather than using a copy) you need to give your code a security permission and set the ControlThread property to true. (see link for example)

James
+1  A: 
CultureInfo culture = (CultureInfo)CultureInfo.CurrentCulture.Clone();

culture.DateTimeFormat.DateSeparator = "/";
culture.DateTimeFormat.ShortDatePattern = "dd/MM/yyyy";

//dekadikoi arithmoi
culture.NumberFormat.NumberDecimalSeparator = ".";
Thread.CurrentThread.CurrentCulture = culture;
Thread.CurrentThread.CurrentUICulture = culture;

You may wish to use:

CultureInfo culture = (CultureInfo)CultureInfo.CurrentUICulture.Clone();

instead.

Jon Hanna