Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
CultureInfo Constructor (String)

CultureInfo Constructor (String)

Initializes a new instance of the CultureInfo class based on the culture specified by name.

Namespace: System.Globalization
Assembly: mscorlib (in mscorlib.dll)

public CultureInfo (
	string name
)
public CultureInfo (
	String name
)
public function CultureInfo (
	name : String
)

Parameters

name

A predefined CultureInfo name, Name of an existing CultureInfo, or Windows-only culture name.

Exception typeCondition

ArgumentNullException

name is a null reference (Nothing in Visual Basic).

ArgumentException

name is not a valid culture name.

-or-

In .NET Compact Framework applications, culture is not supported by the operating system of the device.

The CultureInfo 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. The predefined CultureInfo names are listed in the CultureInfo class topic.

The LCID property of the new CultureInfo is set to the culture identifier associated with the specified name.

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 culture identifier associated with the specified culture name matches the culture identifier of the current culture of Windows, this constructor creates a CultureInfo that uses those overrides, including user settings for the properties of the DateTimeFormatInfo instance returned by the DateTimeFormat property, and the properties of the NumberFormatInfo instance returned by the NumberFormat property. 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.

If the culture identifier associated with the specified culture name does not match the culture identifier of the current culture of Windows, this constructor creates a CultureInfo that uses the default values for the specified culture.

The UseUserOverride property is always set to true.

For example, suppose that "Arabic - Saudi Arabia" (culture name "ar-SA", culture identifier "0x0401") is the current culture of Windows and the user changed the calendar from Hijri to Gregorian.

  • With CultureInfo("ar-SA") (culture identifier "0x0401"), Calendar is set to GregorianCalendar (which is the user setting) and UseUserOverride is set to true.

  • With CultureInfo("th-TH") (culture identifier "0x041E"), Calendar is set to ThaiBuddhistCalendar (which is the default calendar for "th-TH") and UseUserOverride is set to true.

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.

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

Community Additions

ADD
Show:
© 2015 Microsoft