Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET: Are there any differences between InvariantCulture and en-US?

Given the following two cultures:

CultureInfo c1 = InvariantCulture; CultureInfo c2 = new CultureInfo("en-US"); 

and i were to examine every piece of information specific to both cultures, e.g.:

c1.DateTimeInfo.ShortDatePattern; c2.DateTimeInfo.ShortDatePattern;  c1.DateTimeInfo.LongDatePattern; c2.DateTimeInfo.LongDatePattern;  c1.NumberFormat.CurrencyDecimalDigits; c2.NumberFormat.CurrencyDecimalDigits;  c1.TextInfo.IsRightToLeft; c2.TextInfo.IsRightToLeft; 

Would i find any differences?

In other words, is the InvariantCulture, for all purposes, identical to the "en-US" culture?

like image 402
Ian Boyd Avatar asked Feb 24 '10 20:02

Ian Boyd


People also ask

What does InvariantCulture mean?

The CultureInfo. InvariantCulture property is used if you are formatting or parsing a string that should be parseable by a piece of software independent of the user's local settings. The default value is CultureInfo. InstalledUICulture so the default CultureInfo is depending on the executing OS's settings.

How do you set CultureInfo InvariantCulture?

You specify the invariant culture by name by using an empty string ("") in the call to a CultureInfo instantiation method. CultureInfo. InvariantCulture also retrieves an instance of the invariant culture. It can be used in almost any method in the System.


2 Answers

Yes.

For example: InvariantCulture uses the international symbol for currency: "¤" versus the dollar sign: "$" when formatting currency.

For the most part, however, they're very similar.

like image 54
David Morton Avatar answered Sep 19 '22 04:09

David Morton


There are some actual differences (check both values in a Watch window), but the most relevant difference is the intent. InvariantCulture shows your intent of parsing some data in a culture independent, if english related, manner, whereas en-US declares your actual intent to parse data in a US specific manner.

like image 30
Vinko Vrsalovic Avatar answered Sep 19 '22 04:09

Vinko Vrsalovic