Partilhar via


Names Associated with a CultureInfo Object 

There are several interesting names associated with CultureInfo objects and objects belonging to related classes such as CompareInfo. For example, a CultureInfo object may have a CultureInfo.Name property that has a distinct value from its CultureInfo.CompareInfo.Name property.

CultureInfo, Constructed from a Culture Name

First, let us consider three examples in which System.Globalization.CultureInfo.#ctor(System.String) is used to construct a CultureInfo object. The name values passed in are, respectively:

  • "en-US" for English (United States)

  • "de-DE_phoneb" for German (Germany) with phonebook sort, an alternate sort

  • "fj-FJ" for a custom culture. We will assume for the sake of example that this custom culture uses the "en-US" sort order for string comparisons.

Let's look at the values each of these objects will return for CultureInfo.ToString, CultureInfo.Name, and CultureInfo.TextInfo.CultureName and CultureInfo.CompareInfo.Name.

Method en-US de-DE_phoneb Custom Culture

(passed to constructor)

en-US

de-DE_phoneb

fj-FJ

CultureInfo.ToString()

en-US

de-DE_phoneb

fj-FJ

CultureInfo.Name

en-US

de-DE

fj-FJ

CultureInfo.TextInfo.CultureName

en-US

de-DE

fj-FJ

CultureInfo.CompareInfo.Name   

en-US

de-DE_phoneb

en-US

ToString will always return exactly the value passed into the constructor, except that it will "normalize" the capitalization: for example, if an application passes "En-Us" to the constructor, ToString would return "en-US". CultureInfo.Name, will always give a "short" form of the name that excludes any indication of an alternate sort: for example, if an application passes "de-DE_phoneb" to the constructor, CultureInfo.Name would return "de-DE"; CultureInfo.TextInfo.CultureName is always identical to CultureInfo.Name. Finally, CultureInfo.CompareInfo.Name will return the name of the sort, even if (as in our Custom Culture example) that is completely unrelated to the name of the culture itself.

In addition, each culture has a DisplayName, an EnglishName, and a NativeName; there are also several names that identify the language associated with the culture.

CultureInfo, Constructed from a Culture Identifier

Next, let us consider three similar cases, but using System.Globalization.CultureInfo.#ctor(System.Int32) instead of System.Globalization.CultureInfo.#ctor(System.String). In this case, the culture values passed to the constructor are, respectively:

  • 0x0409 for English (United States)

  • 0x10407 for German (Germany) with phonebook sort

  • 0x0c00 for custom culture "fj-FJ". This will work only if "fj-FJ" is the current default user culture. Again, we will assume for the sake of example that this custom culture uses the "en-US" sort order for string comparisons.

These objects will return the exact same names as in the previous example:

Method en-US de-DE_phoneb Custom Culture

(passed to constructor)

0x0409

0x10407

0x0c00

CultureInfo.ToString()

en-US

de-DE_phoneb

fj-FJ

CultureInfo.Name

en-US

de-DE

fj-FJ

CultureInfo.TextInfo.CultureName

en-US

de-DE

fj-FJ

CultureInfo.CompareInfo.Name   

en-US

de-DE_phoneb

en-US

See Also

Reference

CultureInfo
CompareInfo

Concepts

Names Associated with a RegionInfo Object

Other Resources

Encoding and Localization