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

Viewed 8454

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?

6 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.

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.

Well, if you look at what your snippet of code might produce:

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

Console.WriteLine( c1.DateTimeFormat.ShortDatePattern.ToString());
Console.WriteLine( c2.DateTimeFormat.ShortDatePattern.ToString());

Console.WriteLine( c1.DateTimeFormat.LongDatePattern.ToString());
Console.WriteLine( c2.DateTimeFormat.LongDatePattern.ToString());

Console.WriteLine( c1.NumberFormat.CurrencyDecimalDigits.ToString());
Console.WriteLine( c2.NumberFormat.CurrencyDecimalDigits.ToString());

Console.WriteLine( c1.TextInfo.IsRightToLeft.ToString());
Console.WriteLine( c2.TextInfo.IsRightToLeft.ToString());

You'll see some differences:

MM/dd/yyyy
M/d/yyyy
dddd, dd MMMM yyyy
dddd, MMMM dd, yyyy
2
2
False
False

And just think, when the US loses it's backbone and decides to start using European style dates or moves to the metric system (the metric system is the tool of the devil! My car gets forty rods to the hogshead and that's the way I likes it!), the InvariantCulture can just coolly and smoothly stay the way it is. So all those dates you've stashed away in a database in text form using the InvariantCulture will continue to just work...

Short answer yes. InvariantCulture is what it says, not a specific culture. It is english, but not a specific region

you can read more about it here : MSDN

I know they have a different CultureName and LCID (see this list).

Additionally, the currency symbols are different - ¤ for InvariantCulture and $ for en-US.

From InvariantCulture:

It is used in almost any method in the Globalization namespace that requires a culture.

Suggesting that for the most part, they are interchangeable. However, the names do state intent, so you should think about that when using CultureInfo.

Related