views:

401

answers:

5

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  A: 

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.

David Morton
To quote MSDN: *“The InvariantCulture property represents neither a neutral nor a specific culture. It represents a third type of culture that is culture-insensitive. It is associated with the English language but not with a country or region.”* ... Thus it makes sense to behave for the most part as English (though for the weird US date format I would have loved to see something sane) but the currency would just be nonsense :)
Joey
And a logical date format: yyyy-MM-dd as well.
danbystrom
Drat. So trying to parse a money string with the InvariantCulture will work nowhere in the world.
Ian Boyd
+1  A: 

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

Jeremy B.
+2  A: 

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.

Vinko Vrsalovic
A: 

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.

Oded
A: 

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

Michael Burr