Is invariant culture the same as neutral culture(en)

  • Thread starter Thread starter Tony Johansson
  • Start date Start date
T

Tony Johansson

Hi

Below is some docs from MSDN about culture invariant. Is culture-invariant
the same as the neutral culture en(English) because the docs say it is
associated with the English language but not with any country or region ?
So according to me the definition for culture invariant matches the
definition for neutral culture en(English)

The invariant culture is culture-insensitive. Your application specifies the
invariant culture by name using an empty string ("") or by its language
identifier. InvariantCulture retrieves an instance of the invariant culture.
It is associated with the English language but not with any country/region.
It is used in almost any method in the Globalization namespace that requires
a culture.

//Tony
 
Hi

Below is some docs from MSDN about culture invariant. Is culture-invariant
the same as the neutral culture en(English) because the docs say it is
associated with the English language but not with any country or region ?
So according to me the definition for culture invariant matches the
definition for neutral culture en(English)

The invariant culture is culture-insensitive. Your application specifies the
invariant culture by name using an empty string ("") or by its language
identifier. InvariantCulture retrieves an instance of the invariant culture.
It is associated with the English language but not with any country/region.
It is used in almost any method in the Globalization namespace that requires
a culture.

//Tony

No, they are not the same, as several properties of these two objects
are different. Whether these have a great effect on anything in a given
use is a question only you can answer in a situation you have.

This program shows the differences:

CultureInfo ic = CultureInfo.InvariantCulture;
CultureInfo nd = new CultureInfo("en");

foreach (PropertyInfo pi in typeof(CultureInfo).GetProperties())
{
string sIC = pi.GetValue(ic, null).ToString();
string sEN = pi.GetValue(nd, null).ToString();
if (sIC != sEN) {
System.Diagnostics.Debug.WriteLine(
"Different [{0}] values: {1}, {2}", pi.Name, sIC, sEN);
}
}

Different [LCID] values: 127, 9
Different [KeyboardLayoutId] values: 127, 9
Different [Name] values: , en
Different [IetfLanguageTag] values: , en
Different [DisplayName] values: Invariant Language (Invariant Country),
English
Different [NativeName] values: Invariant Language (Invariant Country),
English
Different [EnglishName] values: Invariant Language (Invariant Country),
English
Different [TwoLetterISOLanguageName] values: iv, en
Different [ThreeLetterISOLanguageName] values: ivl, eng
Different [ThreeLetterWindowsLanguageName] values: IVL, ENU
Different [CompareInfo] values: CompareInfo - , CompareInfo - en
Different [TextInfo] values: TextInfo - , TextInfo - en
Different [IsNeutralCulture] values: False, True
Different [CultureTypes] values: SpecificCultures, FrameworkCultures,
NeutralCultures, FrameworkCultures
Different [UseUserOverride] values: False, True
Different [IsReadOnly] values: True, False
 
Tony Johansson said:
Hi

Below is some docs from MSDN about culture invariant. Is culture-invariant
the same as the neutral culture en(English) because the docs say it is
associated with the English language but not with any country or region ?
So according to me the definition for culture invariant matches the
definition for neutral culture en(English)

Is NULL and nothing the same thing? They sound the same, but they are not
precisely. You should be able to compare nothing to nothing, you cannot do
the same with NULL. That is the best way I can describe the difference. I
have not looked under the hood to confirm this, exactly.

Invariant Culture is best used for storing strings from a variety of
cultures (languages, if you will, at least in this context) in a way where
they are not tied to any language or culture. English is chosen, as it is
the highest level language in programming (for proof, find a programming
book in another language).

I am not sure I have made this any clearer, however.

What is the context you are looking at invariant culture for?

--
Peace and Grace,
Greg

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

************************************************
| Think outside the box! |
************************************************
 
IMO it doesn't matter ;-)

The purpose of the invariant culture is basically to be able to get a value
and convert to/from to its text representation on any computer on earth but
using this common invariant culture that will never change.

The en culture could be very close for historical reasons but a change is
not impossible strictly speaking (let's say that in 2050, a new date format
will be widely adopted by english speaking countries).

So even if in practice, it's unlikely you'll see a difference it's best to
just use each one depending on the purpose regardless for their actual
differences...
 
Back
Top