Export (0) Print
Expand All

CultureInfo.CultureInfo(String, Boolean) Constructor

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.

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

public CultureInfo (
	string name,
	bool useUserOverride
)
public CultureInfo (
	String name, 
	boolean useUserOverride
)
public function CultureInfo (
	name : String, 
	useUserOverride : boolean
)
Not applicable.

Parameters

name

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

useUserOverride

A Boolean that denotes whether to use the user-selected culture settings (true) or the default culture settings (false).

Exception typeCondition

ArgumentNullException

name is null.

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 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 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.

If the UseUserOverride 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 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.

Otherwise, this constructor creates a CultureInfo that uses the default values for the specified culture.

The value of the useUserOverride parameter becomes the value of the UseUserOverride property.

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), Calendar is set to GregorianCalendar (which is the user setting) and UseUserOverride is set to true.

  • With CultureInfo("ar-SA", false), Calendar is set to HijriCalendar (which is the default calendar for "ar-SA") and UseUserOverride is set to false.

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

  • With CultureInfo("th-TH", false), Calendar is set to ThaiBuddhistCalendar (which is the default calendar for "th-TH") and UseUserOverride is set to false.

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.

Windows 98, Windows Server 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 Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

XNA Framework

Supported in: 1.0

Community Additions

ADD
Show:
© 2014 Microsoft