.NET Framework Class Library CultureInfo Constructor (Int32) Updated: June 2010 Initializes a new instance of the CultureInfo class based on the culture specified by the culture identifier.
Namespace:
System.Globalization
Assembly:
mscorlib (in mscorlib.dll)

Syntax
Public Sub New ( _
culture As Integer _
)
public CultureInfo(
int culture
)
public:
CultureInfo(
int culture
)
new :
culture:int -> CultureInfo

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. If the specified culture identifier 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. If the specified culture identifier does not match the identifier of the current Windows culture, 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) is the current Windows culture 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 use a CultureInfo constructor overload that accepts a useUserOverride parameter and set it 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.
|
|
Biblioteca de clases de .NET Framework CultureInfo (Constructor) (Int32) Inicializa una nueva instancia de la clase CultureInfo de acuerdo con la referencia cultural especificada por el identificador de la misma.
Espacio de nombres:
System.Globalization
Ensamblado:
mscorlib (en mscorlib.dll)

Sintaxis
Public Sub New ( _
culture As Integer _
)
public CultureInfo(
int culture
)
public:
CultureInfo(
int culture
)
new :
culture:int -> CultureInfo

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 al identificador 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. Si el identificador de referencia cultural especificado 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 ni los valores de las propiedades. Si el identificador de referencia cultural no coincide con el identificador de la referencia cultural actual de Windows, este constructor crea un objeto CultureInfo que utiliza los valores predeterminados de la referencia cultural especificada. La propiedad UseUserOverride siempre se establece en true. 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 usar la configuración predeterminada de .NET Framework para la moneda, debe usar en la aplicación una sobrecarga del constructor CultureInfo que acepte un parámetro useUserOverride y establecerlo 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.
|
|