.NET Framework Class Library CultureInfo Constructor (Int32, Boolean) Updated: June 2010 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.
Namespace:
System.Globalization
Assembly:
mscorlib (in mscorlib.dll)

Syntax
Public Sub New ( _
culture As Integer, _
useUserOverride As Boolean _
)
public CultureInfo(
int culture,
bool useUserOverride
)
public:
CultureInfo(
int culture,
bool useUserOverride
)
new :
culture:int *
useUserOverride:bool -> CultureInfo
Parameters- culture
- Type: System..::.Int32
A predefined CultureInfo identifier, LCID property of an existing CultureInfo object, or Windows-only culture identifier.
- useUserOverride
- Type: System..::.Boolean
A Boolean that denotes whether to use the user-selected culture settings (true) or the default culture settings (false).

Exceptions

Remarks
Predefined culture identifiers are listed in the National Language Support (NLS) API Reference at the Go Global Developer Center. 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 use of the locale name constructor CultureInfo..::.CultureInfo is encouraged, as locale names are preferred to LCIDs. For custom locales the locale name is required. The user might choose to override some of the values associated with the current culture of Windows 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)" (http://blogs.msdn.com/shawnste/archive/2005/04/05/405694.aspx). If the UseUserOverride property is set to true and the specified culture identifier matches the 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 has 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 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. Note |
|---|
For backwards compatibility, a culture constructed using a culture parameter of 0x0004 or 0x7c04 will have a Name property of zh-CHS or zh-CHT, respectively. You should instead prefer to construct the culture using the current standard culture names of zh-Hans or zh-Hant, unless you have a reason for using the older names. |
Notes to CallersThe .NET Framework version 3.5 and earlier versions throw an ArgumentException if culture is not a valid culture identifier. Starting with the .NET Framework version 4, this constructor throws a CultureNotFoundException.

Version Information
.NET FrameworkSupported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0 .NET Framework Client ProfileSupported in: 4, 3.5 SP1

Platforms
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role not supported), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

See Also

Change History
Date | History | Reason |
|---|
June 2010
| Updated exception information. |
Content bug fix.
|
May 2010
| Added information about initializing the invariant culture. |
Customer feedback.
|
|
Biblioteca de clases de .NET Framework CultureInfo (Constructor) (Int32, Boolean) Inicializa una nueva instancia de la clase CultureInfo de acuerdo con la referencia cultural especificada por el identificador y con el valor booleano que especifica si se va a utilizar la configuración de referencia cultural del sistema seleccionada por el usuario.
Espacio de nombres:
System.Globalization
Ensamblado:
mscorlib (en mscorlib.dll)

Sintaxis
Public Sub New ( _
culture As Integer, _
useUserOverride As Boolean _
)
public CultureInfo(
int culture,
bool useUserOverride
)
public:
CultureInfo(
int culture,
bool useUserOverride
)
new :
culture:int *
useUserOverride:bool -> CultureInfo
Parámetros- culture
- Tipo: System..::.Int32
Identificador CultureInfo predefinido, propiedad LCID de un objeto CultureInfo existente, o identificador de referencia cultural sólo de Windows.
- useUserOverride
- Tipo: System..::.Boolean
Valor booleano que indica si se utiliza la configuración de referencia cultural seleccionada por el usuario (true) o la configuración de referencia cultural predeterminada (false).

Excepciones

Comentarios
Los identificadores de referencia cultural predefinidos se enumeran en National Language Support (NLS) API Reference en el Centro de desarrolladores Go Global. En la mayoría de los casos, el parámetro culture se asigna al identificador regional NLS (Compatibilidad con el idioma nacional) correspondiente. El valor del parámetro culture pasa a ser el valor de la propiedad LCID del nuevo CultureInfo. Se aconseja el uso del constructor de configuración regional CultureInfo..::.CultureInfo, puesto que se prefieren nombres de configuración regional a identificadores de configuración regional (LCID). Para las configuraciones regionales personalizadas se requiere el nombre de la configuración regional. El usuario puede optar por invalidar algunos de los valores asociados a la referencia cultural actual de Windows a través de de la configuración referente a las opciones de configuración regional y de idioma del Panel de control. Por ejemplo, el usuario puede mostrar la fecha en un formato diferente o utilizar una moneda diferente a la predeterminada para la referencia cultural. Las aplicaciones normalmente no deberían permitir invalidaciones de usuario. Observe que no permitir reemplazos no garantiza la estabilidad de datos; vea la entrada del blog "Culture data shouldn't be considered stable (except for Invariant)" (http://blogs.msdn.com/shawnste/archive/2005/04/05/405694.aspx). Si la propiedad UseUserOverride está establecida en true y el identificador de la referencia cultural especificada coincide con el identificador de la referencia cultural actual de Windows, este constructor crea un objeto CultureInfo que utiliza los nuevos valores, incluida la configuración del usuario para las propiedades de la instancia de DateTimeFormatInfo devuelta por la propiedad DateTimeFormat y las propiedades de la instancia de NumberFormatInfo devuelta por la propiedad NumberFormat. Si la configuración del usuario no es compatible con la referencia cultural asociada a CultureInfo (por ejemplo, si el calendario seleccionado no es uno de OptionalCalendars), no se definen los resultados de los métodos y los valores de las propiedades. En caso contrario, este constructor crea una CultureInfo que utiliza los valores predeterminados de la referencia cultural especificada. El valor del parámetro useUserOverride pasa a ser el valor de la propiedad UseUserOverride. Por ejemplo, suponga que la referencia cultural actual de Windows es "Árabe (Arabia Saudí)" y que el usuario ha cambiado el calendario de Hijri a Gregoriano. En las referencias culturales que utilizan el euro, .NET Framework y Windows XP establecen el euro como moneda predeterminada. Esto no ocurre, sin embargo, en las versiones anteriores de Windows. Por consiguiente, si el usuario de una versión antigua de Windows no ha cambiado la moneda a través de la configuración referente a las opciones de configuración regional y de idioma del Panel de control, la moneda podría ser incorrecta. Para utilizar la configuración predeterminada de .NET Framework de moneda, la aplicación debe establecer el parámetro useUserOverride en false. Nota |
|---|
Por razones de compatibilidad con versiones anteriores, una referencia cultural construida usando un parámetro culture de 0x0004 o 0x7c04 tendrá una propiedad Name de zh-CHS o zh-CHT, respectivamente. En su lugar, debe preferir construir la cadena de la referencia cultural usando los nombres de la referencia cultural estándar zh-Hans o zh-Hant, a menos que tenga una razón para usar los nombres anteriores. |
Notas para los llamadores.NET Framework versión 3.5 y las versiones anteriores producen una ArgumentException si culture no es un identificador de referencia cultural válido. A partir de .NET Framework versión 4, este constructor produce una CultureNotFoundException.

Información de versión
.NET FrameworkCompatible con: 4, 3.5, 3.0, 2.0, 1.1, 1.0 .NET Framework Client ProfileCompatible con: 4, 3.5 SP1

Plataformas
Windows 7, Windows Vista SP1 o posterior, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (no se admite Server Core), Windows Server 2008 R2 (se admite Server Core con SP1 o posterior), Windows Server 2003 SP2
.NET Framework no admite todas las versiones de todas las plataformas. Para obtener una lista de las versiones compatibles, vea Requisitos de sistema de .NET Framework.

Vea también

Historial de cambios
Fecha | Historial | Motivo |
|---|
Junio de 2010
| Actualizado la información de excepciones. |
Corrección de errores de contenido.
|
Mayo de 2010
| Información agregada sobre cómo inicializar la referencia cultural de todos los idiomas. |
Comentarios de los clientes.
|
|