Export (0) Print
Expand All

CultureInfo Constructor (Int32, Boolean)

.NET Framework 1.1

Initializes a new instance of the CultureInfo class based on the culture specified by the culture identifier and on the Boolean that specifies whether to use the user-selected culture settings from the system.

[Visual Basic]
Public Sub New( _
   ByVal culture As Integer, _
   ByVal useUserOverride As Boolean _
)
[C#]
public CultureInfo(
   int culture,
 bool useUserOverride
);
[C++]
public: CultureInfo(
   int culture,
 bool useUserOverride
);
[JScript]
public function CultureInfo(
   culture : int,
 useUserOverride : Boolean
);

Parameters

culture
A predefined CultureInfo identifier or the LCID property of an existing CultureInfo.
useUserOverride
A Boolean that denotes whether to use the user-selected culture settings (true) or the default culture settings (false).

Exceptions

Exception Type Condition
ArgumentOutOfRangeException culture is less than zero.
ArgumentException culture is not a valid culture identifier.

Remarks

The predefined culture identifiers are listed in the CultureInfo class topic.

In most cases, the culture parameter is mapped to the corresponding National Language Support (NLS) locale identifier. The value of the culture parameter becomes the value of the LCID property of the new CultureInfo.

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 and the specified culture identifier 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, the properties of the NumberFormatInfo instance returned by the NumberFormat property, and the properties of the CompareInfo instance returned by the CompareInfo 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" (culture name "ar-SA", culture identifier "0x0401") is the current culture of Windows and the user changed the calendar from Hijri to Gregorian.

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, set the useUserOverride parameter to false.

If a security decision depends on a string comparison or a case-change operation, use the InvariantCulture to ensure that the behavior will be consistent regardless of the culture settings of the system.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

CultureInfo Class | CultureInfo Members | System.Globalization Namespace | CultureInfo Constructor Overload List | LCID | UseUserOverride

Show:
© 2015 Microsoft