asp.net.ph

CultureInfo Class

System.Globalization Namespace


Represents information about a specific culture including the names of the culture, the writing system, and the calendar used, as well as access to culture-specific objects that provide methods for common operations, such as formatting dates and sorting strings.

CultureInfo Class Members

Collapse   Constructors

Visibility Constructor Parameters
public CultureInfo ( String name )
public CultureInfo ( String name , Boolean useUserOverride )
public CultureInfo ( Int32 culture )
public CultureInfo ( Int32 culture , Boolean useUserOverride )

Collapse   Properties

Visibility Name Value Type Accessibility
public Calendar Calendar [ Get ]
public CompareInfo CompareInfo [ Get ]
public CultureTypes CultureTypes [ Get ]
public static CurrentCulture CultureInfo [ Get , Set ]
public static CurrentUICulture CultureInfo [ Get , Set ]
public DateTimeFormat DateTimeFormatInfo [ Get , Set ]
public static DefaultThreadCurrentCulture CultureInfo [ Get , Set ]
public static DefaultThreadCurrentUICulture CultureInfo [ Get , Set ]
public DisplayName String [ Get ]
public EnglishName String [ Get ]
public IetfLanguageTag String [ Get ]
public static InstalledUICulture CultureInfo [ Get ]
public static InvariantCulture CultureInfo [ Get ]
public IsNeutralCulture Boolean [ Get ]
public IsReadOnly Boolean [ Get ]
public KeyboardLayoutId Int32 [ Get ]
public LCID Int32 [ Get ]
public Name String [ Get ]
public NativeName String [ Get ]
public NumberFormat NumberFormatInfo [ Get , Set ]
public OptionalCalendars Calendar [ Get ]
public Parent CultureInfo [ Get ]
public TextInfo TextInfo [ Get ]
public ThreeLetterISOLanguageName String [ Get ]
public ThreeLetterWindowsLanguageName String [ Get ]
public TwoLetterISOLanguageName String [ Get ]
public UseUserOverride Boolean [ Get ]

Collapse   Methods

Visibility Name Parameters Return Type
public ClearCachedData ( ) Void
public Clone ( ) Object
public static CreateSpecificCulture ( String name ) CultureInfo
public Equals ( Object value ) Boolean
public GetConsoleFallbackUICulture ( ) CultureInfo
public static GetCultureInfo ( Int32 culture ) CultureInfo
public static GetCultureInfo ( String name ) CultureInfo
public static GetCultureInfo ( String name , String altName ) CultureInfo
public static GetCultureInfoByIetfLanguageTag ( String name ) CultureInfo
public static GetCultures ( CultureTypes types ) CultureInfo
public GetFormat ( Type formatType ) Object
public GetHashCode ( ) Int32
public static ReadOnly ( CultureInfo ci ) CultureInfo
public ToString ( ) String

Remarks

The CultureInfo class holds culture-specific information, such as the associated language, sublanguage, country/region, calendar, and cultural conventions. This class also provides access to culture-specific instances of DateTimeFormatInfo, NumberFormatInfo, CompareInfo, and TextInfo. These objects contain the information required for culture-specific operations, such as casing, formatting dates and numbers, and comparing strings.

The String class indirectly uses this class to obtain information about the default culture.

Culture Names and Identifiers

Culture names follow the RFC 1766 standard in the format <languagecode2>-<country/regioncode2>, where <languagecode2> is a lowercase two-letter code derived from ISO 639-1 and <country/regioncode2> is an uppercase two-letter code derived from ISO 3166. For example, U.S. English is en-US.

In cases where a two-letter language code is not available, the three-letter code derived from ISO 639-2 is used. For example, the three-letter code div is used for cultures that use the Dhivehi language.

Some culture names have suffixes that specify the script. For example, -Cyrl specifies the Cyrillic script, -Latn specifies the Latin script.

The following predefined CultureInfo names and identifiers are accepted and used by this class and other classes in the System.Globalization namespace.

 Show me 

Invariant, Neutral, and Specific Cultures

The cultures are generally grouped into three sets: the invariant culture, the neutral cultures, and the specific cultures.

The invariant culture is culture-insensitive. You can specify the invariant culture by name using an empty string ( "" ). InvariantCulture retrieves an instance of the invariant culture. It is associated with the English language but not with any country/region. It can be used in almost any method in the Globalization namespace that requires a culture. The invariant culture must be used only by processes that require culture-independent results, such as system services; otherwise, it produces results that might be linguistically incorrect or culturally inappropriate.

A neutral culture is a culture that is associated with a language but not with a country/region. A specific culture is a culture that is associated with a language and a country/region. For example, fr is a neutral culture and fr-FR is a specific culture. Note that zh-CHS ( Simplified Chinese ) and zh-CHT ( Traditional Chinese ) are neutral cultures.

The following example lists the available CultureInfo names for each culture type.

 Show me 

The cultures have a hierarchy, such that the parent of a specific culture is a neutral culture and the parent of a neutral culture is the invariant culture. The Parent property returns the neutral culture associated with a specific culture.

If the resources for the specific culture are not available in the system, the resources for the neutral culture are used; if the resources for the neutral culture are not available, the resources embedded in the main assembly are used.

The list of cultures in the Windows API is slightly different from the list of cultures in the .NET Framework. For example, the neutral culture zh-CHT for Chinese (Traditional) is not available in the Windows API. If interoperability with Windows is required, use a specific culture that is defined in the operating system. This will ensure consistency with the equivalent Windows locale, which is identified with the same LCID.

A DateTimeFormatInfo or a NumberFormatInfo can be created only for the invariant culture or for specific cultures, not for neutral cultures.

Control Panel Overrides

The user might choose to override some of the values associated with the current culture of Windows through Regional and Language Options ( or Regional Options or Regional Settings ) in Control Panel. For example, the user might choose to display the date in a different format or to use a currency other than the default for the culture.

If the UseUserOverride property is set to true, the properties of the DateTimeFormat instance, the NumberFormat instance, and the TextInfo instance are also retrieved from the user settings. If the user settings are incompatible with the culture associated with the CultureInfo ( for example, if the selected calendar is not one of the OptionalCalendars ), the results of the methods and the values of the properties are undefined.

For cultures that use the euro, the .NET Framework and Windows XP set the default currency as euro; however, older versions of Windows do not. Therefore, if the user of an older version of Windows has not changed the currency setting through Regional Options or Regional Settings in Control Panel, the currency might be incorrect. To use the .NET Framework default setting for the currency, use a CultureInfo constructor overload that accepts a useUserOverride parameter and set it to false.

This class implements the ICloneable interface to enable duplication of CultureInfo objects. It also implements IFormatProvider to supply formatting information to applications.

See Also

RegionInfo   ASP.NET Globalization Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph