Initializes a new instance of the CultureInfo class based on the culture specified by name and on the Boolean that specifies whether to use the user-selected culture settings from the system.
Assembly: mscorlib (in mscorlib.dll)
public CultureInfo( string name, bool useUserOverride )
public: CultureInfo( String^ name, bool useUserOverride )
new : name:string * useUserOverride:bool -> CultureInfo
Public Sub New ( name As String, useUserOverride As Boolean )
For a list of predefined culture names, see the National Language Support (NLS) API Reference at the Go Global Developer Center. In addition, starting with Windows 10, name can be any valid BCP-47 language tag.
If name is StringEmpty, the constructor creates an instance of the invariant culture; this is equivalent to retrieving the value of the property.
The user might choose to override some of the values associated with the current Windows culture through the regional and language options portion of 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.
Applications should typically not disallow user overrides. Note that disallowing overrides does not itself guarantee data stability; see the blog entry Culture data shouldn't be considered stable (except for Invariant).
If the property is set to true and the culture identifier associated with the specified culture name matches the culture identifier of the current Windows culture, this constructor creates a CultureInfo that uses those overrides, including user settings for the properties of the DateTimeFormatInfo instance returned by the property, and the properties of the NumberFormatInfo instance returned by the 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 , the results of the methods and the values of the properties are undefined.
Otherwise, this constructor creates a CultureInfo that uses the default values for the specified culture.
For example, suppose that Arabic (Saudi Arabia) is the current culture of Windows and the user changed the calendar from Hijri to Gregorian.
With CultureInfo("ar-SA", true), is set to GregorianCalendar (which is the user setting) and is set to true.
With CultureInfo("ar-SA", false), is set to HijriCalendar (which is the default calendar for ar-SA) and is set to false.
With CultureInfo("th-TH", true), is set to ThaiBuddhistCalendar (which is the default calendar for th-TH) and is set to true.
With CultureInfo("th-TH", false), is set to ThaiBuddhistCalendar (which is the default calendar for th-TH) and is set to false.
The property of the new CultureInfo is set to the culture identifier associated with the specified name.
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 do this. Therefore, if the user of an older version of Windows has not changed the currency setting through the regional and language options portion of Control Panel, the currency might be incorrect. To use the .NET Framework default setting for the currency, the application should set the useUserOverride parameter to false.
Notes to Callers:
The .NET Framework 3.5 and earlier versions throw an ArgumentException if name is not a valid culture name. Starting with the .NET Framework 4, this constructor throws a CultureNotFoundException. Starting with apps that run under the .NET Framework 4 or later on Windows 7 or later, the method attempts to retrieve a CultureInfo object whose identifier is name from the operating system; if the operating system does not support that culture, and if name is not the name of a supplementary or replacement culture, the method throws a CultureNotFoundException exception.
Available since 1.1