How to set CultureInfo.InvariantCulture default?

1 Empty string specifies InvariantCulture in config.file

By default, Culture and UICulture are set to "" in the config.

   <system.web>
      <globalization culture="" />
   </system.web>

2 You can also define on your Thread


C# doesn't make it a comma by default, it's your culture. Try setting the culture explictly,

System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo("de-DE");

Link: http://msdn.microsoft.com/en-us/library/ms425914(v=office.12).aspx


You can set the culture of the current thread to any culture you want:

Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;

Note that changing the culture also affects things like string comparison and sorting, date formats and parsing of dates and numbers.


Since .NET Framework version 4.5 and .NET Core/Standard 1.0 you can change the culture for the whole application, rather than just the current Thread, by modifying the CultureInfo.DefaultThreadCurrentCulture and CultureInfo.DefaultThreadCurrentUICulture properties:

CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;
CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.InvariantCulture;

Tags:

C#

Double