Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
3636 lines (3108 sloc) 296 KB
<Type Name="CultureInfo" FullName="System.Globalization.CultureInfo">
<TypeSignature Language="C#" Value="public class CultureInfo : ICloneable, IFormatProvider" />
<TypeSignature Language="ILAsm" Value=".class public sequential ansi serializable beforefieldinit CultureInfo extends System.Object implements class System.ICloneable, class System.IFormatProvider" />
<TypeSignature Language="DocId" Value="T:System.Globalization.CultureInfo" />
<TypeSignature Language="VB.NET" Value="Public Class CultureInfo&#xA;Implements ICloneable, IFormatProvider" />
<TypeSignature Language="C++ CLI" Value="public ref class CultureInfo : ICloneable, IFormatProvider" />
<TypeSignature Language="F#" Value="type CultureInfo = class&#xA; interface ICloneable&#xA; interface IFormatProvider" />
<AssemblyInfo>
<AssemblyName>System.Globalization</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime</AssemblyName>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
</AssemblyInfo>
<Base>
<BaseTypeName>System.Object</BaseTypeName>
</Base>
<Interfaces>
<Interface>
<InterfaceName>System.ICloneable</InterfaceName>
</Interface>
<Interface>
<InterfaceName>System.IFormatProvider</InterfaceName>
</Interface>
</Interfaces>
<Attributes>
<Attribute FrameworkAlternate="netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netframework-4.8">
<AttributeName>System.Runtime.InteropServices.ComVisible(true)</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="netframework-1.1;netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0">
<AttributeName>System.Serializable</AttributeName>
</Attribute>
</Attributes>
<Docs>
<summary>Provides information about a specific culture (called a *locale* for unmanaged code development). The information includes the names for the culture, the writing system, the calendar used, the sort order of strings, and formatting for dates and numbers.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Globalization.CultureInfo> class provides culture-specific information, such as the language, sublanguage, country/region, calendar, and conventions associated with a particular culture. This class also provides access to culture-specific instances of the <xref:System.Globalization.DateTimeFormatInfo>, <xref:System.Globalization.NumberFormatInfo>, <xref:System.Globalization.CompareInfo>, and <xref:System.Globalization.TextInfo> objects. These objects contain the information required for culture-specific operations, such as casing, formatting dates and numbers, and comparing strings. The <xref:System.Globalization.CultureInfo> class is used either directly or indirectly by classes that format, parse, or manipulate culture-specific data, such as <xref:System.String>, <xref:System.DateTime>, <xref:System.DateTimeOffset>, and the numeric types.
In this section:
[Culture names and identifiers](#CultureNames)
[Invariant, neutral, and specific cultures](#Invariant)
[Custom cultures](#Custom)
[Dynamic culture data](#Dynamic)
[CultureInfo and cultural data](#cultureinfo-and-cultural-data)
[The current culture and current UI culture](#Current)
[Getting all cultures](#GetAll)
[Culture and threads](#Threads)
[Culture and application domains](#AppDomain)
[Culture and task-based asynchronous operations](#Async)
[CultureInfo object serialization](#Serialization)
[Control Panel overrides](#CPanel)
[Alternate sort orders](#AlternateSort)
[Culture and Windows apps](#Windows)
<a name="CultureNames"></a>
## Culture names and identifiers
The <xref:System.Globalization.CultureInfo> class specifies a unique name for each culture, based on RFC 4646. The name is a combination of an ISO 639 two-letter lowercase culture code associated with a language and an ISO 3166 two-letter uppercase subculture code associated with a country or region. In addition, for apps that target [!INCLUDE[net_v40_short](~/includes/net-v40-short-md.md)] or later and are running under Windows 10 or later, culture names that correspond to valid BCP-47 language tags are supported.
> [!NOTE]
> When a culture name is passed to a class constructor or a method such as <xref:System.Globalization.CultureInfo.CreateSpecificCulture%2A> or <xref:System.Globalization.CultureInfo>, its case is not significant.
The format for the culture name based on RFC 4646 is *languagecode2*>-*country/regioncode2*, where *languagecode2* is the two-letter language code and *country/regioncode2* is the two-letter subculture code. Examples include ja-JP for Japanese (Japan) and en-US for English (United States). In cases where a two-letter language code is not available, a three-letter code derived from ISO 639-2 is used.
Note that some culture names also specify an ISO 15924 script. For example, Cyrl specifies the Cyrillic script and Latn specifies the Latin script. A culture name that includes a script uses the pattern *languagecode2*-*scripttag*-*country/regioncode2*. An example of this type of culture name is uz-Cyrl-UZ for Uzbek (Cyrillic, Uzbekistan). On Windows operating systems before Windows Vista, a culture name that includes a script uses the pattern *languagecode2*-*country/regioncode2*-*scripttag*, for example, uz-UZ-Cyrl for Uzbek (Cyrillic, Uzbekistan).
A neutral culture is specified by only the two-letter lowercase language code. For example, fr specifies the neutral culture for French, and de specifies the neutral culture for German.
> [!NOTE]
> There are two culture names that contradict this rule. The cultures Chinese (Simplified), named zh-Hans, and Chinese (Traditional), named zh-Hant, are neutral cultures. The culture names represent the current standard and should be used unless you have a reason for using the older names zh-CHS and zh-CHT.
A culture identifier is a standard international numeric abbreviation and has the components necessary to uniquely identify one of the installed cultures. Your application can use predefined culture identifiers or define custom identifiers.
Certain predefined culture names and identifiers are used by this and other classes in the <xref:System.Globalization?displayProperty=nameWithType> namespace. For detailed culture information for Windows systems, see the **Language tag** column in the [list of language/region names supported by Windows](https://docs.microsoft.com/openspecs/windows_protocols/ms-lcid/a9eac961-e77d-41a6-90a5-ce1a8b0cdb9c). Culture names follow the standard defined by [BCP 47](https://tools.ietf.org/html/bcp47).
Remember that the culture names and identifiers represent only a subset of cultures that can be found on a particular computer. Windows versions or service packs can change the available cultures. Applications add custom cultures using the <xref:System.Globalization.CultureAndRegionInfoBuilder> class. Users add their own custom cultures using the Microsoft Locale Builder tool. Microsoft Locale Builder is written in managed code using the `CultureAndRegionInfoBuilder` class.
Several distinct names are closely associated with a culture, notably the names associated with the following class members:
- <xref:System.Globalization.CultureInfo.ToString%2A?displayProperty=nameWithType>
- <xref:System.Globalization.CultureInfo.Name%2A?displayProperty=nameWithType>
- <xref:System.Globalization.CompareInfo.Name%2A?displayProperty=nameWithType>
<a name="Invariant"></a>
## Invariant, neutral, and specific cultures
The cultures are generally grouped into three sets: invariant cultures, neutral cultures, and specific cultures.
An invariant culture is culture-insensitive. Your application specifies the invariant culture by name using an empty string ("") or by its identifier. <xref:System.Globalization.CultureInfo.InvariantCulture%2A> defines an instance of the invariant culture. It is associated with the English language but not with any country/region. It is used in almost any method in the `Globalization` namespace that requires a culture.
A neutral culture is a culture that is associated with a language but not with a country/region. A specific culture is a culture that is associated with a language and a country/region. For example, fr is the neutral name for the French culture, and fr-FR is the name of the specific French (France) culture. Note that Chinese (Simplified) and Chinese (Traditional) are also considered neutral cultures.
Creating an instance of a <xref:System.Globalization.CompareInfo> class for a neutral culture is not recommended because the data it contains is arbitrary. To display and sort data, specify both the language and region. Additionally, the <xref:System.Globalization.CompareInfo.Name%2A> property of a <xref:System.Globalization.CompareInfo> object created for a neutral culture returns only the country and does not include the region.
The defined cultures have a hierarchy in which the parent of a specific culture is a neutral culture and the parent of a neutral culture is the invariant culture. The <xref:System.Globalization.CultureInfo.Parent%2A> property contains the neutral culture associated with a specific culture. Custom cultures should define the <xref:System.Globalization.CultureInfo.Parent%2A> property in conformance with this pattern.
If the resources for a specific culture are not available in the operating system, the resources for the associated neutral culture are used. If the resources for the neutral culture are not available, the resources embedded in the main assembly are used. For more information on the resource fallback process, see [Packaging and Deploying Resources](~/docs/framework/resources/packaging-and-deploying-resources-in-desktop-apps.md).
The list of locales in the Windows API is slightly different from the list of cultures supported by the .NET Framework. If interoperability with Windows is required, for example, through the p/invoke mechanism, the application should use a specific culture that is defined for the operating system. Use of the specific culture ensures consistency with the equivalent Windows locale, which is identified with a locale identifier that is the same as <xref:System.Globalization.CultureInfo.LCID%2A>.
A <xref:System.Globalization.DateTimeFormatInfo> or a <xref:System.Globalization.NumberFormatInfo> can be created only for the invariant culture or for specific cultures, not for neutral cultures.
If <xref:System.Globalization.DateTimeFormatInfo.Calendar%2A?displayProperty=nameWithType> is the <xref:System.Globalization.TaiwanCalendar> but the <xref:System.Threading.Thread.CurrentCulture%2A?displayProperty=nameWithType> is not set to zh-TW, then <xref:System.Globalization.DateTimeFormatInfo.NativeCalendarName%2A?displayProperty=nameWithType>, <xref:System.Globalization.DateTimeFormatInfo.GetEraName%2A?displayProperty=nameWithType>, and <xref:System.Globalization.DateTimeFormatInfo.GetAbbreviatedEraName%2A?displayProperty=nameWithType> return an empty string ("").
<a name="Custom"></a>
## Custom cultures
In addition to the predefined cultures supported by the Windows operating system and the .NET Framework, the .NET Framework supports three types of custom cultures:
- New cultures that supplement the cultures available in Windows or the .NET Framework. For example, an application could install a <xref:System.Globalization.CultureInfo> object that represents the fj-FJ (or Fijan (Fiji)) culture on a system.
- Replacement cultures whose properties are different from the properties of the standard cultures supported by Windows and the .NET Framework.
- Standard cultures with user overrides. The user can use the **Region and Language** application in **Control Panel** to customize an existing culture's property values.
> [!NOTE]
> You can use the <xref:System.Globalization.CultureAndRegionInfoBuilder> class to define, save, and register custom cultures that either supplement or replace existing cultures. The <xref:System.Globalization.CultureAndRegionInfoBuilder.Save%2A?displayProperty=nameWithType> method creates a Locale Data Markup Language (LDML) file that can be used to install a custom culture on target systems. For step-by step information on using the <xref:System.Globalization.CultureAndRegionInfoBuilder> class to create a new or replacement culture, see the <xref:System.Globalization.CultureAndRegionInfoBuilder> class topic.
Because the .NET Framework supports custom cultures, you should consider the following when working with culture-specific data:
- Custom cultures can have values that exceed the ranges of the predefined cultures. For example, some cultures have unusually long month names, unexpected date or time formats, or other unusual data.
- When you display culture-specific data in the user interface, you should respect the user's customizations; for example, the user might want a 24-hour clock or a yyyyMMdd date format.
- Remember that custom cultures override default values. Therefore, you cannot consider culture data to be stable. Country names, number and date formats, and spellings may change in the future. If you want to serialize culture-sensitive data such as date and time strings to be passed to the date and time parsing functions, you should use the invariant culture or a specific .
The <xref:System.Globalization.CultureInfo.CultureTypes%2A> property value of custom cultures installed on a system includes the <xref:System.Globalization.CultureTypes?displayProperty=nameWithType> flag, and custom cultures are assigned an <xref:System.Globalization.CultureInfo.LCID%2A> property value of `LOCALE_CUSTOM_UNSPECIFIED` (0x1000, or 4096). Note that, starting with Windows 10, this value is also assigned to system-defined cultures that lack complete cultural data.
## CultureInfo and cultural data
.NET derives its cultural data from a one of a variety of sources, depending on implementation, platform, and version:
- In .NET Framework 3.5 and earlier versions, cultural data is provided by both the Windows operating system and the .NET Framework.
- In .NET Framework 4 and later versions, cultural data is provided by the Windows operating system.
- In all versions of .NET Core running on Windows, cultural data is provided by the Windows operating system.
- In all versions of .NET Core running on Unix platforms, cultural data is provided by the [International Components for Unicode (ICU) Library](http://site.icu-project.org/). The specific version of the ICU Library depends on the individual operating system.
Because of this, a culture available on a particular .NET implementation, platform, or version may not be available on a different .NET implementation, platform, or version.
Some `CultureInfo` objects differ depending on the underlying platform. In particular, "zh-CN", or Chinese (Simplified, China) and zh-TW, or Chinese (Traditional, Taiwan), are available cultures on Windows systems, but they are aliased cultures on Unix systems. "zh-CN" is an alias for the "zh-Hans-CN" culture, and "zh-TW" is an alias for the "zh-Hant-TW" culture. Aliased cultures are not returned by calls to the <xref:System.Globalization.CultureInfo.GetCultures%2A> method and may have different property values, including different <xref:System.Globalization.CultureInfo.Parent> cultures, than their Windows counterparts. For the zh-CN and zh-TW cultures, these differenes include the following:
- On Windows systems, the parent culture of the "zh-CN" culture is "zh-Hans", and the parent culture of the "zh-TW" culture is "zh-Hant". The parent culture of both these cultures is "zh". On Unix systems, the parents of both cultures are "zh". This means that, if you don't provide culture-specific resources for the "zh-CN" or "zh-TW" cultures but do provide a resources for the neutral "zh-Hans" or "zh-Hant" culture, your application will load the resources for the neutral culture on Windows but not on Unix. On Unix systems, you must explicitly set the thread's <xref:System.Globalization.CultureInfo.CurrentUICulture> to either "zh-Hans" or "zh-Hant".
- On Windows systems, calling <xref:System.Globalization.CultureInfo.Equals%2A?displayProperty=nameWithType> on an instance that represents the "zh-CN" culture and passing it a "zh-Hans-CN" instance returns `true`. On Unix systems, the method call returns `false`. This behavior also applies to calling <xref:System.Globalization.CultureInfo.Equals%2A> on a "zh-TW" <xref:System.Globalization.CultureInfo> instance and passing it a "zh-Hant-Tw" instance.
<a name="Dynamic"></a>
## Dynamic culture data
Except for the invariant culture, culture data is dynamic. This is true even for the predefined cultures. For example, countries or regions adopt new currencies, change their spellings of words, or change their preferred calendar, and culture definitions change to track this. Custom cultures are subject to change without notice, and any specific culture might be overridden by a custom replacement culture. Also, as discussed below, an individual user can override cultural preferences. Applications should always obtain culture data at run time.
> [!CAUTION]
> When saving data, your application should use the invariant culture, a binary format, or a specific culture-independent format. Data saved according to the current values associated with a particular culture, other than the invariant culture, might become unreadable or might change in meaning if that culture changes.
<a name="Current"></a>
## The current culture and current UI culture
Every thread in a .NET application has a current culture and a current UI culture. The current culture determines the formatting conventions for dates, times, numbers, and currency values, the sort order of text, casing conventions, and the ways in which strings are compared. The current UI culture is used to retrieve culture-specific resources at runtime.
> [!NOTE]
> For information on how the current and current UI culture is determined on a per-thread basis, see the [Culture and threads](#Threads) section. For information on how the current and current UI culture is determined on threads executing in a new application domain, and on threads that cross application domain boundaries, see the [Culture and application domains](#AppDomain) section. For information on how the current and current is determined on threads performing task-based asynchronous operations, see the [Culture and task-based asynchronous operations](#Async) section.
For more detailed information on the current culture, see the <xref:System.Globalization.CultureInfo.CurrentCulture%2A?displayProperty=nameWithType> property topic. For more detailed information on the current UI culture, see the <xref:System.Globalization.CultureInfo.CurrentUICulture%2A?displayProperty=nameWithType> property topic.
### Retrieving the current and current UI cultures
You can get a <xref:System.Globalization.CultureInfo> object that represents the current culture in either of two ways:
- By retrieving the value of the <xref:System.Globalization.CultureInfo.CurrentCulture%2A?displayProperty=nameWithType> property.
- By retrieving the value of the [Thread.CurrentThread.CurrentCulture](<xref:System.Threading.Thread.CurrentCulture>) property.
The following example retrieves both property values, compares them to show that they are equal, and displays the name of the current culture.
[!code-csharp[System.Globalization.CultureInfo#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/System.Globalization.CultureInfo/cs/Current1.cs#1)]
[!code-vb[System.Globalization.CultureInfo#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/System.Globalization.CultureInfo/vb/Current1.vb#1)]
You can get a <xref:System.Globalization.CultureInfo> object that represents the current UI culture in either of two ways:
- By retrieving the value of the <xref:System.Globalization.CultureInfo.CurrentUICulture%2A?displayProperty=nameWithType> property.
- By retrieving the value of the [Thread.CurrentThread.CurrentUICulture](<xref:System.Threading.Thread.CurrentUICulture>) property.
The following example retrieves both property values, compares them to show that they are equal, and displays the name of the current UI culture.
[!code-csharp[System.Globalization.CultureInfo#2](~/samples/snippets/csharp/VS_Snippets_CLR_System/System.Globalization.CultureInfo/cs/CurrentUI1.cs#2)]
[!code-vb[System.Globalization.CultureInfo#2](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/System.Globalization.CultureInfo/vb/CurrentUI1.vb#2)]
### Setting the current and current UI cultures
To change the culture and UI culture of a thread, do the following:
1. Instantiate a <xref:System.Globalization.CultureInfo> object that represents that culture by calling a <xref:System.Globalization.CultureInfo> class constructor and passing it the name of the culture. The <xref:System.Globalization.CultureInfo.%23ctor%28System.String%29> constructor instantiates a <xref:System.Globalization.CultureInfo> object that reflects user overrides if the new culture is the same as the current Windows culture. The <xref:System.Globalization.CultureInfo.%23ctor%28System.String%2CSystem.Boolean%29> constructor allows you to specify whether the newly instantiated <xref:System.Globalization.CultureInfo> object reflects user overrides if the new culture is the same as the current Windows culture.
2. Assign the <xref:System.Globalization.CultureInfo> object to the <xref:System.Globalization.CultureInfo.CurrentCulture%2A?displayProperty=nameWithType> or <xref:System.Globalization.CultureInfo.CurrentUICulture%2A?displayProperty=nameWithType> property on .NET Core and .NET Framework 4.6 and later versions. (On .NET Framework 4.5.2 and earlier versions, youc an assign the `CultureInfo` object to the <xref:System.Threading.Thread.CurrentCulture%2A?displayProperty=nameWithType> or <xref:System.Threading.Thread.CurrentUICulture%2A?displayProperty=nameWithType> property.)
The following example retrieves the current culture. If it is anything other than the French (France) culture, it changes the current culture to French (France). Otherwise, it changes the current culture to French (Luxembourg).
[!code-csharp[System.Globalization.CultureInfo#3](~/samples/snippets/csharp/VS_Snippets_CLR_System/System.Globalization.CultureInfo/cs/Change1.cs#3)]
[!code-vb[System.Globalization.CultureInfo#3](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/System.Globalization.CultureInfo/vb/Change1.vb#3)]
The following example retrieves the current culture. If it is anything other the Slovenian (Slovenia) culture, it changes the current culture to Slovenian (Slovenia). Otherwise, it changes the current culture to Croatian (Croatia).
[!code-csharp[System.Globalization.CultureInfo#4](~/samples/snippets/csharp/VS_Snippets_CLR_System/System.Globalization.CultureInfo/cs/ChangeUI1.cs#4)]
[!code-vb[System.Globalization.CultureInfo#4](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/System.Globalization.CultureInfo/vb/ChangeUI1.vb#4)]
<a name="GetAll"></a>
## Getting all cultures
You can retrieve an array specific categories of cultures or of all the cultures available on the local computer by calling the <xref:System.Globalization.CultureInfo.GetCultures%2A> method. For example, you can retrieve custom cultures, specific cultures, or neutral cultures either alone or in combination.
The following example calls the <xref:System.Globalization.CultureInfo.GetCultures%2A> method twice, first with the <xref:System.Globalization.CultureTypes?displayProperty=nameWithType> enumeration member to retrieve all custom cultures, and then with the <xref:System.Globalization.CultureTypes?displayProperty=nameWithType> enumeration member to retrieve all replacement cultures.
[!code-csharp[System.Globalization.CultureInfo#5](~/samples/snippets/csharp/VS_Snippets_CLR_System/System.Globalization.CultureInfo/cs/GetCultures1.cs#5)]
[!code-vb[System.Globalization.CultureInfo#5](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/System.Globalization.CultureInfo/vb/GetCultures1.vb#5)]
<a name="Threads"></a>
## Culture and threads
When a new application thread is started, its current culture and current UI culture are defined by the current system culture, and not by the current thread culture. The following example illustrates the difference. It sets the current culture and current UI culture of an application thread to the French (France) culture (fr-FR). If the current culture is already fr-FR, the example sets it to the English (United States) culture (en-US). It displays three random numbers as currency values and then creates a new thread, which, in turn, displays three more random numbers as currency values. But as the output from the example shows, the currency values displayed by the new thread do not reflect the formatting conventions of the French (France) culture, unlike the output from the main application thread.
[!code-csharp[System.Globalization.CultureInfo.Class.Thread#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.globalization.cultureinfo.class.thread/cs/defaultthread1.cs#1)]
[!code-vb[System.Globalization.CultureInfo.Class.Thread#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.cultureinfo.class.thread/vb/defaultthread1.vb#1)]
In versions of the .NET Framework before the [!INCLUDE[net_v45](~/includes/net-v45-md.md)], the most common way to ensure that the main application thread shares the same culture with all other worker threads is to pass either the name of the application-wide culture or a <xref:System.Globalization.CultureInfo> object that represents the application-wide culture to a <xref:System.Threading.ParameterizedThreadStart?displayProperty=nameWithType> delegate. The following example uses this approach to ensure that the currency values displayed by two threads reflect the formatting conventions of the same culture.
[!code-csharp[System.Globalization.CultureInfo.Class.Thread#2](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.globalization.cultureinfo.class.thread/cs/perthread1.cs#2)]
[!code-vb[System.Globalization.CultureInfo.Class.Thread#2](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.cultureinfo.class.thread/vb/perthread1.vb#2)]
You can set the culture and UI culture of thread pool threads in a similar manner by calling the <xref:System.Threading.ThreadPool.QueueUserWorkItem%28System.Threading.WaitCallback%2CSystem.Object%29?displayProperty=nameWithType> method.
Starting with the [!INCLUDE[net_v45](~/includes/net-v45-md.md)], you can set the culture and UI culture of all threads in an application domain more directly by assigning a <xref:System.Globalization.CultureInfo> object that represents that culture to the <xref:System.Globalization.CultureInfo.DefaultThreadCurrentCulture%2A> and <xref:System.Globalization.CultureInfo.DefaultThreadCurrentUICulture%2A> properties. The following example uses these properties to ensure that all threads in the default application domain share the same culture.
[!code-csharp[System.Globalization.CultureInfo.Class.Thread#3](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.globalization.cultureinfo.class.thread/cs/setthreads1.cs#3)]
[!code-vb[System.Globalization.CultureInfo.Class.Thread#3](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.cultureinfo.class.thread/vb/setthreads1.vb#3)]
> [!WARNING]
> Although the <xref:System.Globalization.CultureInfo.DefaultThreadCurrentCulture%2A> and <xref:System.Globalization.CultureInfo.DefaultThreadCurrentUICulture%2A> properties are static members, they define the default culture and default UI culture only for the application domain that is current at the time these property values are set. For more information, see the next section, [Culture and application domains](#AppDomain).
When you assign values to the <xref:System.Globalization.CultureInfo.DefaultThreadCurrentCulture%2A> and <xref:System.Globalization.CultureInfo.DefaultThreadCurrentUICulture%2A> properties, the culture and UI culture of the threads in the application domain also change if they have not explicitly been assigned a culture. However, these threads reflect the new culture settings only while they execute in the current application domain. If these threads execute in another application domain, their culture becomes the default culture defined for that application domain. As a result, we recommend that you always set the culture of the main application thread, and not rely on the <xref:System.Globalization.CultureInfo.DefaultThreadCurrentCulture%2A> and <xref:System.Globalization.CultureInfo.DefaultThreadCurrentUICulture%2A> properties to change it.
<a name="AppDomain"></a>
## Culture and application domains
<xref:System.Globalization.CultureInfo.DefaultThreadCurrentCulture%2A> and <xref:System.Globalization.CultureInfo.DefaultThreadCurrentUICulture%2A> are static properties that explicitly define a default culture only for the application domain that is current when the property value is set or retrieved. The following example sets the default culture and default UI culture in the default application domain to French (France), and then uses the <xref:System.AppDomainSetup> class and the <xref:System.AppDomainInitializer> delegate to set the default culture and UI culture in a new application domain to Russian (Russia). A single thread then executes two methods in each application domain. Note that the thread's culture and UI culture are not explicitly set; they are derived from the default culture and UI culture of the application domain in which the thread is executing. Note also that the <xref:System.Globalization.CultureInfo.DefaultThreadCurrentCulture%2A> and <xref:System.Globalization.CultureInfo.DefaultThreadCurrentUICulture%2A> properties return the default <xref:System.Globalization.CultureInfo> values of the application domain that is current when the method call is made.
[!code-csharp[System.Globalization.CultureInfo.Class.AppDomain#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.globalization.cultureinfo.class.appdomain/cs/appdomainex1.cs#1)]
[!code-vb[System.Globalization.CultureInfo.Class.AppDomain#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.cultureinfo.class.appdomain/vb/appdomainex1.vb#1)]
For more information about cultures and application domains, see the "Application Domains and Threads" section in the [Application Domains](~/docs/framework/app-domains/application-domains.md) topic.
<a name="Async"></a>
## Culture and task-based asynchronous operations
The [task-based asynchronous programming pattern](~/docs/standard/parallel-programming/task-based-asynchronous-programming.md) uses <xref:System.Threading.Tasks.Task> and <xref:System.Threading.Tasks.Task%601> objects to asynchronously execute delegates on thread pool threads. The specific thread on which a particular task runs is not known in advance, but is determined only at runtime.
For apps that target the [!INCLUDE[net_v46](~/includes/net-v46-md.md)] or later versions, culture is part of an asynchronous operation's context. In other words, starting with apps that target the [!INCLUDE[net_v46](~/includes/net-v46-md.md)], asynchronous operations by default inherit the values of the <xref:System.Globalization.CultureInfo.CurrentCulture%2A> and <xref:System.Globalization.CultureInfo.CurrentUICulture%2A> properties of the thread from which they are launched. If the current culture or current UI culture differs from the system culture, the current culture crosses thread boundaries and becomes the current culture of the thread pool thread that is executing an asynchronous operation.
The following example provides a simple illustration. It uses the <xref:System.Runtime.Versioning.TargetFrameworkAttribute> attribute to target the [!INCLUDE[net_v46](~/includes/net-v46-md.md)]. The example defines a <xref:System.Func%601> delegate, `formatDelegate`, that returns some numbers formatted as currency values. The example changes the current system culture to either French (France) or, if French (France) is already the current culture, English (United States). It then:
- Invokes the delegate directly so that it runs synchronously on the main app thread.
- Creates a task that executes the delegate asynchronously on a thread pool thread.
- Creates a task that executes the delegate synchronously on the main app thread by calling the <xref:System.Threading.Tasks.Task.RunSynchronously%2A?displayProperty=nameWithType> method.
As the output from the example shows, when the current culture is changed to French (France), the current culture of the thread from which tasks are invoked asynchronously becomes the current culture for that asynchronous operation.
[!code-csharp[System.Globalization.CultureInfo.Class.Async#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.globalization.cultureinfo.class.async/cs/asyncculture1.cs#1)]
[!code-vb[System.Globalization.CultureInfo.Class.Async#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.cultureinfo.class.async/vb/asyncculture1.vb#1)]
For apps that target versions of the .NET Framework prior to the [!INCLUDE[net_v46](~/includes/net-v46-md.md)], or for apps that do not target a particular version of the .NET Framework, the culture of the calling thread is not part of a task's context. Instead, unless one is explicitly defined, the culture of new threads by default is the system culture. The following example, which is identical to the previous example except that it lacks the <xref:System.Runtime.Versioning.TargetFrameworkAttribute> attribute, illustrates this. Because the system culture of the system on which the example executed was English (United States), the culture of the task that executes asynchronously on a thread pool thread is en-US rather than fr-FR.
[!code-csharp[System.Globalization.CultureInfo.Class.Async#2](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.globalization.cultureinfo.class.async/cs/asyncculture2.cs#2)]
[!code-vb[System.Globalization.CultureInfo.Class.Async#2](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.cultureinfo.class.async/vb/asyncculture2.vb#2)]
For apps that target versions of the .NET Framework from the [!INCLUDE[net_v45](~/includes/net-v45-md.md)] and later but prior to the [!INCLUDE[net_v46](~/includes/net-v46-md.md)], you can use the <xref:System.Globalization.CultureInfo.DefaultThreadCurrentCulture%2A> and <xref:System.Globalization.CultureInfo.DefaultThreadCurrentUICulture%2A> properties to ensure that the culture of the calling thread is used in asynchronous tasks that execute on thread pool threads. The following example is identical to the previous example, except that it uses the <xref:System.Globalization.CultureInfo.DefaultThreadCurrentCulture%2A> property to ensure that thread pool threads have the same culture as the main app thread.
[!code-csharp[System.Globalization.CultureInfo.Class.Async#3](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.globalization.cultureinfo.class.async/cs/asyncculture3.cs#3)]
[!code-vb[System.Globalization.CultureInfo.Class.Async#3](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.cultureinfo.class.async/vb/asyncculture3.vb#3)]
<xref:System.Globalization.CultureInfo.DefaultThreadCurrentCulture%2A> and <xref:System.Globalization.CultureInfo.DefaultThreadCurrentUICulture%2A> are per-app domain properties; that is, they establish a default culture for all threads not explicitly assigned a culture in a specific application domain. However, for apps that target the [!INCLUDE[net_v46](~/includes/net-v46-md.md)] or later, the culture of the calling thread remains part of an asynchronous task's context even if the task crosses app domain boundaries.
The following example shows that the calling thread's culture remains the current culture of a task-based asynchronous operation even if the method that the task is executing crosses application domain boundaries. It defines a class, `DataRetriever`, with a single method, `GetFormattedNumber`, that returns a random double-precision floating-point number between 1 and 1,000 formatted as a currency value. A first task is run that simply instantiates a `DataRetriever` instance and calls its `GetFormattedNumber` method. A second task reports its current application domain, creates a new application domain, instantiates a `DataRetriever` instance in the new application domain, and calls its `GetFormattedNumber` method. As the output from the example shows, the current culture has remained the same in the calling thread, the first task, and the second task both when it was executing in the main application domain and the second application domain.
[!code-csharp[System.Globalization.CultureInfo.Class.Async#4](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.globalization.cultureinfo.class.async/cs/asyncculture4.cs#4)]
[!code-vb[System.Globalization.CultureInfo.Class.Async#4](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.cultureinfo.class.async/vb/asyncculture4.vb#4)]
<a name="Serialization"></a>
## CultureInfo object serialization
When a <xref:System.Globalization.CultureInfo> object is serialized, all that is actually stored is <xref:System.Globalization.CultureInfo.Name%2A> and <xref:System.Globalization.CultureInfo.UseUserOverride%2A>. It is successfully de-serialized only in an environment where that <xref:System.Globalization.CultureInfo.Name%2A> has the same meaning. The following three examples show why this is not always the case:
- If the <xref:System.Globalization.CultureInfo.CultureTypes%2A> property value is <xref:System.Globalization.CultureTypes.InstalledWin32Cultures?displayProperty=nameWithType>, and if that culture was first introduced in a particular version of the Windows operating system, it is not possible to deserialize it on an earlier version of Windows. For example, if a culture was introduced in Windows 10, it cannot be deserialized on Windows 8.
- If the <xref:System.Globalization.CultureInfo.CultureTypes%2A> value is <xref:System.Globalization.CultureTypes.UserCustomCulture?displayProperty=nameWithType>, and the computer on which it is de-serialized does not have this user custom culture installed, it is not possible to deserialize it.
- If the <xref:System.Globalization.CultureInfo.CultureTypes%2A> value is <xref:System.Globalization.CultureTypes.ReplacementCultures?displayProperty=nameWithType>, and the computer on which it is de-serialized does not have this replacement culture, it de-serializes to the same name, but not all of the same characteristics. For example, if en-US is a replacement culture on computer A, but not on computer B, and if a <xref:System.Globalization.CultureInfo> object referring to this culture is serialized on computer A and de-serialized on computer B, then none of the custom characteristics of the culture are transmitted. The culture deserializes successfully, but with a different meaning.
<a name="CPanel"></a>
## Control Panel overrides
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. In general, your applications should honor these user overrides.
If <xref:System.Globalization.CultureInfo.UseUserOverride%2A> is `true` and the specified culture matches the current culture of Windows, the <xref:System.Globalization.CultureInfo> uses those overrides, including user settings for the properties of the <xref:System.Globalization.DateTimeFormatInfo> instance returned by the <xref:System.Globalization.CultureInfo.DateTimeFormat%2A> property, and the properties of the <xref:System.Globalization.NumberFormatInfo> instance returned by the <xref:System.Globalization.CultureInfo.NumberFormat%2A> property. If the user settings are incompatible with the culture associated with the <xref:System.Globalization.CultureInfo>, for example, if the selected calendar is not one of the <xref:System.Globalization.CultureInfo.OptionalCalendars%2A>, the results of the methods and the values of the properties are undefined.
<a name="AlternateSort"></a>
## Alternate sort orders
Some cultures support more than one sort order. For example:
- The Spanish (Spain) culture has two sort orders: the default international sort order, and the traditional sort order. When you instantiate a <xref:System.Globalization.CultureInfo> object with the es-ES culture name, the international sort order is used. When you instantiate a <xref:System.Globalization.CultureInfo> object with the es-ES-tradnl culture name, the traditional sort order is used.
- The zh-CN (Chinese (Simplified, PRC)) culture supports two sort orders: by pronunciation (the default) and by stroke count. When you instantiate a <xref:System.Globalization.CultureInfo> object with the zh-CN culture name, the default sort order is used. When you instantiate a <xref:System.Globalization.CultureInfo> object with a local identifier of 0x00020804, strings are sorted by stroke count.
The following table lists the cultures that support alternate sort orders and the identifiers for the default and alternate sort orders.
|Culture name|Culture|Default sort name and identifier|Alternate sort name and identifier|
|------------------|-------------|--------------------------------------|----------------------------------------|
|es-ES|Spanish (Spain)|International: 0x00000C0A|Traditional: 0x0000040A|
|zh-TW|Chinese (Taiwan)|Stroke Count: 0x00000404|Bopomofo: 0x00030404|
|zh-CN|Chinese (PRC)|Pronunciation: 0x00000804|Stroke Count: 0x00020804|
|zh-HK|Chinese (Hong Kong SAR)|Stroke Count: 0x00000c04|Stroke Count: 0x00020c04|
|zh-SG|Chinese (Singapore)|Pronunciation: 0x00001004|Stroke Count: 0x00021004|
|zh-MO|Chinese (Macao SAR)|Pronunciation: 0x00001404|Stroke Count: 0x00021404|
|ja-JP|Japanese (Japan)|Default: 0x00000411|Unicode: 0x00010411|
|ko-KR|Korean (Korea)|Default: 0x00000412|Korean Xwansung - Unicode: 0x00010412|
|de-DE|German (Germany)|Dictionary: 0x00000407|Phone Book Sort DIN: 0x00010407|
|hu-HU|Hungarian (Hungary)|Default: 0x0000040e|Technical Sort: 0x0001040e|
|ka-GE|Georgian (Georgia)|Traditional: 0x00000437|Modern Sort: 0x00010437|
<a name="Windows"></a>
## The current culture and UWP apps
In Universal Windows Platform (UWP) apps, the <xref:System.Globalization.CultureInfo.CurrentCulture%2A> and <xref:System.Globalization.CultureInfo.CurrentUICulture%2A> properties are read-write, just as they are in .NET Framework and .NET Core apps. However, UWP apps recognize a single culture. The <xref:System.Globalization.CultureInfo.CurrentCulture%2A> and <xref:System.Globalization.CultureInfo.CurrentUICulture%2A> properties map to the first value in the [Windows.ApplicationModel.Resources.Core.ResourceManager.DefaultContext.Languages](https://docs.microsoft.com/uwp/api/windows.applicationmodel.resources.core.resourcecontext#properties_) collection.
In .NET Framework and .NET Core apps, the current culture is a per-thread setting, and the <xref:System.Globalization.CultureInfo.CurrentCulture%2A> and <xref:System.Globalization.CultureInfo.CurrentUICulture%2A> properties reflect the culture and UI culture of the current thread only. In UWP apps, the current culture maps to the [Windows.ApplicationModel.Resources.Core.ResourceManager.DefaultContext.Languages](https://docs.microsoft.com/uwp/api/windows.applicationmodel.resources.core.resourcecontext#properties_) collection, which is a global setting. Setting the <xref:System.Globalization.CultureInfo.CurrentCulture%2A> or <xref:System.Globalization.CultureInfo.CurrentUICulture%2A> property changes the culture of the entire app; culture cannot be set on a per-thread basis.
## Examples
The following example shows how to create a <xref:System.Globalization.CultureInfo> object for Spanish (Spain) with the international sort and another <xref:System.Globalization.CultureInfo> object with the traditional sort.
[!code-cpp[System.Globalization.CultureInfo_esES#1](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo_esES/CPP/spanishspain.cpp#1)]
[!code-csharp[System.Globalization.CultureInfo_esES#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Globalization.CultureInfo_esES/CS/spanishspain.cs#1)]
[!code-vb[System.Globalization.CultureInfo_esES#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CultureInfo_esES/VB/spanishspain.vb#1)]
]]></format>
</remarks>
<altmember cref="T:System.Globalization.CultureAndRegionInfoBuilder" />
<altmember cref="T:System.Globalization.RegionInfo" />
</Docs>
<Members>
<MemberGroup MemberName=".ctor">
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Docs>
<summary>Initializes a new instance of the <see cref="T:System.Globalization.CultureInfo" /> class.</summary>
</Docs>
</MemberGroup>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public CultureInfo (int culture);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(int32 culture) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Globalization.CultureInfo.#ctor(System.Int32)" />
<MemberSignature Language="VB.NET" Value="Public Sub New (culture As Integer)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; CultureInfo(int culture);" />
<MemberSignature Language="F#" Value="new System.Globalization.CultureInfo : int -&gt; System.Globalization.CultureInfo" Usage="new System.Globalization.CultureInfo culture" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime</AssemblyName>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Globalization</AssemblyName>
</AssemblyInfo>
<Parameters>
<Parameter Name="culture" Type="System.Int32" Index="0" FrameworkAlternate="netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netframework-1.1;netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netstandard-2.0;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netstandard-2.1" />
</Parameters>
<Docs>
<param name="culture">A predefined <see cref="T:System.Globalization.CultureInfo" /> identifier, <see cref="P:System.Globalization.CultureInfo.LCID" /> property of an existing <see cref="T:System.Globalization.CultureInfo" /> object, or Windows-only culture identifier.</param>
<summary>Initializes a new instance of the <see cref="T:System.Globalization.CultureInfo" /> class based on the culture specified by the culture identifier.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Predefined culture identifiers for cultures available on Windows system are listed in the **Language tag** column in the [list of language/region names supported by Windows](https://docs.microsoft.com/openspecs/windows_protocols/ms-lcid/a9eac961-e77d-41a6-90a5-ce1a8b0cdb9c). Culture names follow the standard defined by [BCP 47](https://tools.ietf.org/html/bcp47).
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 <xref:System.Globalization.CultureInfo.LCID%2A> property of the new <xref:System.Globalization.CultureInfo>.
We recommend that you call the locale name constructor <xref:System.Globalization.CultureInfo.%23ctor%2A?displayProperty=nameWithType>, because locale names are preferable to LCIDs. For custom locales, a 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 <xref:System.Globalization.CultureInfo> that uses those overrides, including user settings for the properties of the <xref:System.Globalization.DateTimeFormatInfo> instance returned by the <xref:System.Globalization.CultureInfo.DateTimeFormat%2A> property, and the properties of the <xref:System.Globalization.NumberFormatInfo> instance returned by the <xref:System.Globalization.CultureInfo.NumberFormat%2A> property. If the user settings are incompatible with the culture associated with the <xref:System.Globalization.CultureInfo> (for example, if the selected calendar is not one of the <xref:System.Globalization.CultureInfo.OptionalCalendars%2A>) 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 <xref:System.Globalization.CultureInfo> that uses the default values for the specified culture.
The <xref:System.Globalization.CultureInfo.UseUserOverride%2A> 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.
- With `CultureInfo("0x0401")` (culture name ar-SA), <xref:System.Globalization.CultureInfo.Calendar%2A> is set to <xref:System.Globalization.GregorianCalendar> (which is the user setting) and <xref:System.Globalization.CultureInfo.UseUserOverride%2A> is set to `true`.
- With `CultureInfo("0x041E")` (culture name th-TH), <xref:System.Globalization.CultureInfo.Calendar%2A> is set to <xref:System.Globalization.ThaiBuddhistCalendar> (which is the default calendar for th-TH) and <xref:System.Globalization.CultureInfo.UseUserOverride%2A> is set to `true`.
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 <xref:System.Globalization.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 <xref:System.Globalization.CultureInfo.Name%2A> 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.
]]></format>
</remarks>
<exception cref="T:System.ArgumentOutOfRangeException">
<paramref name="culture" /> is less than zero.</exception>
<exception cref="T:System.Globalization.CultureNotFoundException">
<paramref name="culture" /> is not a valid culture identifier. See the Notes to Callers section for more information.</exception>
<block subset="none" type="usage">
<para>The [!INCLUDE[net_v35_long](~/includes/net-v35-long-md.md)] and earlier versions throw an <see cref="T:System.ArgumentException" /> if <paramref name="culture" /> is not a valid culture identifier. Starting with the [!INCLUDE[net_v40_long](~/includes/net-v40-long-md.md)], this constructor throws a <see cref="T:System.Globalization.CultureNotFoundException" />. Starting with apps that run under the [!INCLUDE[net_v40_long](~/includes/net-v40-long-md.md)] or later on Windows 7 or later, the method attempts to retrieve a <see cref="T:System.Globalization.CultureInfo" /> object whose identifier is <paramref name="culture" /> from the operating system; if the operating system does not support that culture, the method throws a <see cref="T:System.Globalization.CultureNotFoundException" /> exception.</para>
</block>
<altmember cref="P:System.Globalization.CultureInfo.LCID" />
<altmember cref="P:System.Globalization.CultureInfo.UseUserOverride" />
</Docs>
</Member>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public CultureInfo (string name);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(string name) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Globalization.CultureInfo.#ctor(System.String)" />
<MemberSignature Language="VB.NET" Value="Public Sub New (name As String)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; CultureInfo(System::String ^ name);" />
<MemberSignature Language="F#" Value="new System.Globalization.CultureInfo : string -&gt; System.Globalization.CultureInfo" Usage="new System.Globalization.CultureInfo name" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>System.Globalization</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime</AssemblyName>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2">
<AttributeName>System.Runtime.TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName>System.Security.SecuritySafeCritical</AttributeName>
</Attribute>
</Attributes>
<Parameters>
<Parameter Name="name" Type="System.String" />
</Parameters>
<Docs>
<param name="name">A predefined <see cref="T:System.Globalization.CultureInfo" /> name, <see cref="P:System.Globalization.CultureInfo.Name" /> of an existing <see cref="T:System.Globalization.CultureInfo" />, or Windows-only culture name. <paramref name="name" /> is not case-sensitive.</param>
<summary>Initializes a new instance of the <see cref="T:System.Globalization.CultureInfo" /> class based on the culture specified by name.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
For a list of predefined culture names on Windows systems, see the **Language tag** column in the [list of language/region names supported by Windows](https://docs.microsoft.com/openspecs/windows_protocols/ms-lcid/a9eac961-e77d-41a6-90a5-ce1a8b0cdb9c). Culture names follow the standard defined by [BCP 47](https://tools.ietf.org/html/bcp47). In addition, starting with Windows 10, `name` can be any valid BCP-47 language tag.
If `name` is <xref:System.String.Empty?displayProperty=nameWithType>, the constructor creates an instance of the invariant culture; this is equivalent to retrieving the value of the <xref:System.Globalization.CultureInfo.InvariantCulture%2A> property.
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 culture identifier associated with `name` matches the culture identifier of the current Windows culture, this constructor creates a <xref:System.Globalization.CultureInfo> object that uses those overrides, including user settings for the properties of the <xref:System.Globalization.DateTimeFormatInfo> instance returned by the <xref:System.Globalization.CultureInfo.DateTimeFormat%2A> property, and the properties of the <xref:System.Globalization.NumberFormatInfo> instance returned by the <xref:System.Globalization.CultureInfo.NumberFormat%2A> property. If the user settings are incompatible with the culture associated with the <xref:System.Globalization.CultureInfo>, for example, if the selected calendar is not one of the <xref:System.Globalization.CultureInfo.OptionalCalendars%2A>, the results of the methods and the values of the properties are undefined.
If the culture identifier associated with `name` does not match the culture identifier of the current Windows culture, this constructor creates a <xref:System.Globalization.CultureInfo> object that uses the default values for the specified culture.
The <xref:System.Globalization.CultureInfo.UseUserOverride%2A> property is always set to `true`.
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")`, <xref:System.Globalization.CultureInfo.Calendar%2A> is set to <xref:System.Globalization.GregorianCalendar> (which is the user setting) and <xref:System.Globalization.CultureInfo.UseUserOverride%2A> is set to `true`.
- With `CultureInfo("th-TH")`, <xref:System.Globalization.CultureInfo.Calendar%2A> is set to <xref:System.Globalization.ThaiBuddhistCalendar> (which is the default calendar for th-TH) and <xref:System.Globalization.CultureInfo.UseUserOverride%2A> is set to `true`.
The <xref:System.Globalization.CultureInfo.LCID%2A> property of the new <xref:System.Globalization.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 use a <xref:System.Globalization.CultureInfo> constructor overload that accepts a `useUserOverride` parameter and set it to `false`.
## Examples
The following example retrieves the current culture. If it is anything other than the French (France) culture, it calls the <xref:System.Globalization.CultureInfo.%23ctor%28System.String%29> constructor to instantiate a <xref:System.Globalization.CultureInfo> object that represents the French (France) culture and makes it the current thread culture. Otherwise, it instantiates a <xref:System.Globalization.CultureInfo> object that represents the French (Luxembourg) culture and makes it the current culture.
[!code-csharp[System.Globalization.CultureInfo#3](~/samples/snippets/csharp/VS_Snippets_CLR_System/System.Globalization.CultureInfo/cs/Change1.cs#3)]
[!code-vb[System.Globalization.CultureInfo#3](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/System.Globalization.CultureInfo/vb/Change1.vb#3)]
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="name" /> is null.</exception>
<exception cref="T:System.Globalization.CultureNotFoundException">
<paramref name="name" /> is not a valid culture name. For more information, see the Notes to Callers section.</exception>
<block subset="none" type="usage">
<para>The [!INCLUDE[net_v35_long](~/includes/net-v35-long-md.md)] and earlier versions throw an <see cref="T:System.ArgumentException" /> if <paramref name="name" /> is not a valid culture name. Starting with the [!INCLUDE[net_v40_long](~/includes/net-v40-long-md.md)], this constructor throws a <see cref="T:System.Globalization.CultureNotFoundException" />. Starting with apps that run under the [!INCLUDE[net_v40_long](~/includes/net-v40-long-md.md)] or later on Windows 7 or later, the method attempts to retrieve a <see cref="T:System.Globalization.CultureInfo" /> object whose identifier is <paramref name="name" /> from the operating system; if the operating system does not support that culture, and if <paramref name="name" /> is not the name of a supplementary or replacement culture, the method throws a <see cref="T:System.Globalization.CultureNotFoundException" /> exception.</para>
</block>
<altmember cref="P:System.Globalization.CultureInfo.LCID" />
<altmember cref="P:System.Globalization.CultureInfo.UseUserOverride" />
<altmember cref="M:System.Globalization.CultureInfo.CreateSpecificCulture(System.String)" />
</Docs>
</Member>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public CultureInfo (int culture, bool useUserOverride);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(int32 culture, bool useUserOverride) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Globalization.CultureInfo.#ctor(System.Int32,System.Boolean)" />
<MemberSignature Language="VB.NET" Value="Public Sub New (culture As Integer, useUserOverride As Boolean)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; CultureInfo(int culture, bool useUserOverride);" />
<MemberSignature Language="F#" Value="new System.Globalization.CultureInfo : int * bool -&gt; System.Globalization.CultureInfo" Usage="new System.Globalization.CultureInfo (culture, useUserOverride)" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime</AssemblyName>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Globalization</AssemblyName>
</AssemblyInfo>
<Parameters>
<Parameter Name="culture" Type="System.Int32" Index="0" FrameworkAlternate="netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netframework-1.1;netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netstandard-2.0;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netstandard-2.1" />
<Parameter Name="useUserOverride" Type="System.Boolean" Index="1" FrameworkAlternate="netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netframework-1.1;netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netstandard-2.0;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netstandard-2.1" />
</Parameters>
<Docs>
<param name="culture">A predefined <see cref="T:System.Globalization.CultureInfo" /> identifier, <see cref="P:System.Globalization.CultureInfo.LCID" /> property of an existing <see cref="T:System.Globalization.CultureInfo" /> object, or Windows-only culture identifier.</param>
<param name="useUserOverride">A Boolean that denotes whether to use the user-selected culture settings (<see langword="true" />) or the default culture settings (<see langword="false" />).</param>
<summary>Initializes a new instance of the <see cref="T:System.Globalization.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.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Predefined culture identifiers available on Windows systems are listed in the **Language tag** column in the [list of language/region names supported by Windows](https://docs.microsoft.com/openspecs/windows_protocols/ms-lcid/a9eac961-e77d-41a6-90a5-ce1a8b0cdb9c). Culture names follow the standard defined by [BCP 47](https://tools.ietf.org/html/bcp47).
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 <xref:System.Globalization.CultureInfo.LCID%2A> property of the new <xref:System.Globalization.CultureInfo>.
We recommend that you call the locale name constructor <xref:System.Globalization.CultureInfo.%23ctor%2A?displayProperty=nameWithType>, because locale names are preferable to LCIDs. For custom locales, a 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)](https://go.microsoft.com/fwlink/?LinkId=156850).
If the <xref:System.Globalization.CultureInfo.UseUserOverride%2A> property is set to `true` and the specified culture identifier matches the identifier of the current Windows culture, this constructor creates a <xref:System.Globalization.CultureInfo> that uses those overrides, including user settings for the properties of the <xref:System.Globalization.DateTimeFormatInfo> instance returned by the <xref:System.Globalization.CultureInfo.DateTimeFormat%2A> property, and the properties of the <xref:System.Globalization.NumberFormatInfo> instance returned by the <xref:System.Globalization.CultureInfo.NumberFormat%2A> property. If the user settings are incompatible with the culture associated with the <xref:System.Globalization.CultureInfo>, for example, if the selected calendar is not one of the <xref:System.Globalization.CultureInfo.OptionalCalendars%2A>, the results of the methods and the values of the properties are undefined.
Otherwise, this constructor creates a <xref:System.Globalization.CultureInfo> that uses the default values for the specified culture.
The value of the `useUserOverride` parameter becomes the value of the <xref:System.Globalization.CultureInfo.UseUserOverride%2A> 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.
- With `CultureInfo("0x0401", true)` (culture name ar-SA), <xref:System.Globalization.CultureInfo.Calendar%2A> is set to <xref:System.Globalization.GregorianCalendar> (which is the user setting) and <xref:System.Globalization.CultureInfo.UseUserOverride%2A> is set to `true`.
- With `CultureInfo("0x0401", false)` (culture name ar-SA), <xref:System.Globalization.CultureInfo.Calendar%2A> is set to <xref:System.Globalization.HijriCalendar> (which is the default calendar for ar-SA) and <xref:System.Globalization.CultureInfo.UseUserOverride%2A> is set to `false`.
- With `CultureInfo("0x041E", true)` (culture name th-TH), <xref:System.Globalization.CultureInfo.Calendar%2A> is set to <xref:System.Globalization.ThaiBuddhistCalendar> (which is the default calendar for th-TH) and <xref:System.Globalization.CultureInfo.UseUserOverride%2A> is set to `true`.
- With `CultureInfo("0x041E", false)` (culture name th-TH), <xref:System.Globalization.CultureInfo.Calendar%2A> is set to <xref:System.Globalization.ThaiBuddhistCalendar> (which is the default calendar for th-TH) and <xref:System.Globalization.CultureInfo.UseUserOverride%2A> 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. 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 <xref:System.Globalization.CultureInfo.Name%2A> 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.
]]></format>
</remarks>
<exception cref="T:System.ArgumentOutOfRangeException">
<paramref name="culture" /> is less than zero.</exception>
<exception cref="T:System.Globalization.CultureNotFoundException">
<paramref name="culture" /> is not a valid culture identifier. See the Notes to Callers section for more information.</exception>
<block subset="none" type="usage">
<para>The [!INCLUDE[net_v35_long](~/includes/net-v35-long-md.md)] and earlier versions throw an <see cref="T:System.ArgumentException" /> if <paramref name="culture" /> is not a valid culture identifier. Starting with the [!INCLUDE[net_v40_long](~/includes/net-v40-long-md.md)], this constructor throws a <see cref="T:System.Globalization.CultureNotFoundException" />. Starting with apps that run under the [!INCLUDE[net_v40_long](~/includes/net-v40-long-md.md)] or later on Windows 7 or later, the method attempts to retrieve a <see cref="T:System.Globalization.CultureInfo" /> object whose identifier is <paramref name="culture" /> from the operating system; if the operating system does not support that culture, the method throws a <see cref="T:System.Globalization.CultureNotFoundException" /> exception.</para>
</block>
<altmember cref="P:System.Globalization.CultureInfo.LCID" />
<altmember cref="P:System.Globalization.CultureInfo.UseUserOverride" />
</Docs>
</Member>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public CultureInfo (string name, bool useUserOverride);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(string name, bool useUserOverride) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Globalization.CultureInfo.#ctor(System.String,System.Boolean)" />
<MemberSignature Language="VB.NET" Value="Public Sub New (name As String, useUserOverride As Boolean)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; CultureInfo(System::String ^ name, bool useUserOverride);" />
<MemberSignature Language="F#" Value="new System.Globalization.CultureInfo : string * bool -&gt; System.Globalization.CultureInfo" Usage="new System.Globalization.CultureInfo (name, useUserOverride)" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime</AssemblyName>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Globalization</AssemblyName>
</AssemblyInfo>
<Parameters>
<Parameter Name="name" Type="System.String" Index="0" FrameworkAlternate="netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netframework-1.1;netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netstandard-2.0;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netstandard-2.1" />
<Parameter Name="useUserOverride" Type="System.Boolean" Index="1" FrameworkAlternate="netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netframework-1.1;netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netstandard-2.0;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netstandard-2.1" />
</Parameters>
<Docs>
<param name="name">A predefined <see cref="T:System.Globalization.CultureInfo" /> name, <see cref="P:System.Globalization.CultureInfo.Name" /> of an existing <see cref="T:System.Globalization.CultureInfo" />, or Windows-only culture name. <paramref name="name" /> is not case-sensitive.</param>
<param name="useUserOverride">A Boolean that denotes whether to use the user-selected culture settings (<see langword="true" />) or the default culture settings (<see langword="false" />).</param>
<summary>Initializes a new instance of the <see cref="T:System.Globalization.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.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
For a list of predefined culture names, see the **Language tag** column in the [list of language/region names supported by Windows](https://docs.microsoft.com/openspecs/windows_protocols/ms-lcid/a9eac961-e77d-41a6-90a5-ce1a8b0cdb9c). Culture names follow the standard defined by [BCP 47](https://tools.ietf.org/html/bcp47). In addition, starting with Windows 10, `name` can be any valid BCP-47 language tag.
If `name` is <xref:System.String.Empty?displayProperty=nameWithType>, the constructor creates an instance of the invariant culture; this is equivalent to retrieving the value of the <xref:System.Globalization.CultureInfo.InvariantCulture%2A> 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)](https://go.microsoft.com/fwlink/?LinkId=156850).
If the <xref:System.Globalization.CultureInfo.UseUserOverride%2A> 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 <xref:System.Globalization.CultureInfo> that uses those overrides, including user settings for the properties of the <xref:System.Globalization.DateTimeFormatInfo> instance returned by the <xref:System.Globalization.CultureInfo.DateTimeFormat%2A> property, and the properties of the <xref:System.Globalization.NumberFormatInfo> instance returned by the <xref:System.Globalization.CultureInfo.NumberFormat%2A> property. If the user settings are incompatible with the culture associated with the <xref:System.Globalization.CultureInfo>, for example, if the selected calendar is not one of the <xref:System.Globalization.CultureInfo.OptionalCalendars%2A>, the results of the methods and the values of the properties are undefined.
Otherwise, this constructor creates a <xref:System.Globalization.CultureInfo> that uses the default values for the specified culture.
The value of the `useUserOverride` parameter becomes the value of the <xref:System.Globalization.CultureInfo.UseUserOverride%2A> 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)`, <xref:System.Globalization.CultureInfo.Calendar%2A> is set to <xref:System.Globalization.GregorianCalendar> (which is the user setting) and <xref:System.Globalization.CultureInfo.UseUserOverride%2A> is set to `true`.
- With `CultureInfo("ar-SA", false)`, <xref:System.Globalization.CultureInfo.Calendar%2A> is set to <xref:System.Globalization.HijriCalendar> (which is the default calendar for ar-SA) and <xref:System.Globalization.CultureInfo.UseUserOverride%2A> is set to `false`.
- With `CultureInfo("th-TH", true)`, <xref:System.Globalization.CultureInfo.Calendar%2A> is set to <xref:System.Globalization.ThaiBuddhistCalendar> (which is the default calendar for th-TH) and <xref:System.Globalization.CultureInfo.UseUserOverride%2A> is set to `true`.
- With `CultureInfo("th-TH", false)`, <xref:System.Globalization.CultureInfo.Calendar%2A> is set to <xref:System.Globalization.ThaiBuddhistCalendar> (which is the default calendar for th-TH) and <xref:System.Globalization.CultureInfo.UseUserOverride%2A> is set to `false`.
The <xref:System.Globalization.CultureInfo.LCID%2A> property of the new <xref:System.Globalization.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`.
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="name" /> is null.</exception>
<exception cref="T:System.Globalization.CultureNotFoundException">
<paramref name="name" /> is not a valid culture name. See the Notes to Callers section for more information.</exception>
<block subset="none" type="usage">
<para>The [!INCLUDE[net_v35_long](~/includes/net-v35-long-md.md)] and earlier versions throw an <see cref="T:System.ArgumentException" /> if <paramref name="name" /> is not a valid culture name. Starting with the [!INCLUDE[net_v40_long](~/includes/net-v40-long-md.md)], this constructor throws a <see cref="T:System.Globalization.CultureNotFoundException" />. Starting with apps that run under the [!INCLUDE[net_v40_long](~/includes/net-v40-long-md.md)] or later on Windows 7 or later, the method attempts to retrieve a <see cref="T:System.Globalization.CultureInfo" /> object whose identifier is <paramref name="name" /> from the operating system; if the operating system does not support that culture, and if <paramref name="name" /> is not the name of a supplementary or replacement culture, the method throws a <see cref="T:System.Globalization.CultureNotFoundException" /> exception.</para>
</block>
<altmember cref="P:System.Globalization.CultureInfo.LCID" />
<altmember cref="P:System.Globalization.CultureInfo.UseUserOverride" />
<altmember cref="M:System.Globalization.CultureInfo.CreateSpecificCulture(System.String)" />
</Docs>
</Member>
<Member MemberName="Calendar">
<MemberSignature Language="C#" Value="public virtual System.Globalization.Calendar Calendar { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance class System.Globalization.Calendar Calendar" />
<MemberSignature Language="DocId" Value="P:System.Globalization.CultureInfo.Calendar" />
<MemberSignature Language="VB.NET" Value="Public Overridable ReadOnly Property Calendar As Calendar" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; virtual property System::Globalization::Calendar ^ Calendar { System::Globalization::Calendar ^ get(); };" />
<MemberSignature Language="F#" Value="member this.Calendar : System.Globalization.Calendar" Usage="System.Globalization.CultureInfo.Calendar" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Globalization</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime</AssemblyName>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName>get: System.Security.SecuritySafeCritical</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Globalization.Calendar</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets the default calendar used by the culture.</summary>
<value>A <see cref="T:System.Globalization.Calendar" /> that represents the default calendar used by the culture.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
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 <xref:System.Globalization.CultureInfo.UseUserOverride%2A> is `true` and the specified culture matches the current culture of Windows, the <xref:System.Globalization.CultureInfo> uses those overrides, including user settings for the properties of the <xref:System.Globalization.DateTimeFormatInfo> instance returned by the <xref:System.Globalization.CultureInfo.DateTimeFormat%2A> property, and the properties of the <xref:System.Globalization.NumberFormatInfo> instance returned by the <xref:System.Globalization.CultureInfo.NumberFormat%2A> property. If the user settings are incompatible with the culture associated with the <xref:System.Globalization.CultureInfo>, for example, if the selected calendar is not one of the <xref:System.Globalization.CultureInfo.OptionalCalendars%2A>, the results of the methods and the values of the properties are undefined.
Therefore, if <xref:System.Globalization.CultureInfo.UseUserOverride%2A> is `true`, the value of this property might be different from the default calendar used by the culture.
Your application changes the calendar used by the current <xref:System.Globalization.CultureInfo> by setting the <xref:System.Globalization.DateTimeFormatInfo.Calendar%2A> property of <xref:System.Globalization.CultureInfo.DateTimeFormat%2A>, which is an instance of the <xref:System.Globalization.DateTimeFormatInfo> class. The new calendar must be one of the calendars listed in <xref:System.Globalization.CultureInfo.OptionalCalendars%2A>. <xref:System.Globalization.CultureInfo.DateTimeFormat%2A> also includes other properties that customize the date and time formatting associated with that <xref:System.Globalization.DateTimeFormatInfo.Calendar%2A>.
]]></format>
</remarks>
<altmember cref="T:System.Globalization.Calendar" />
<altmember cref="P:System.Globalization.CultureInfo.DateTimeFormat" />
<altmember cref="T:System.Globalization.DateTimeFormatInfo" />
</Docs>
</Member>
<Member MemberName="ClearCachedData">
<MemberSignature Language="C#" Value="public void ClearCachedData ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance void ClearCachedData() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Globalization.CultureInfo.ClearCachedData" />
<MemberSignature Language="VB.NET" Value="Public Sub ClearCachedData ()" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; void ClearCachedData();" />
<MemberSignature Language="F#" Value="member this.ClearCachedData : unit -&gt; unit" Usage="cultureInfo.ClearCachedData " />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime</AssemblyName>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Globalization</AssemblyName>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<summary>Refreshes cached culture-related information.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Information, such as the default culture and format patterns, is cached the first time it is requested. That information can change during the life of the <xref:System.AppDomain>, for example, when the user modifies the regional and language options portion of Control Panel. However, the <xref:System.Globalization.CultureInfo> class does not automatically detect changes in the system settings.
The <xref:System.Globalization.CultureInfo.ClearCachedData%2A> method clears the cache of <xref:System.Globalization.CultureInfo> objects created by <xref:System.Globalization.CultureInfo.GetCultureInfo%2A> and refreshes the information in the <xref:System.Globalization.CultureInfo.CurrentCulture%2A>, <xref:System.Globalization.CultureInfo.CurrentUICulture%2A>, and <xref:System.Globalization.RegionInfo.CurrentRegion%2A> properties, based on the current system settings.
The <xref:System.Globalization.CultureInfo.ClearCachedData%2A> method does not refresh the information in the <xref:System.Threading.Thread.CurrentCulture%2A?displayProperty=nameWithType> property for existing threads. However, future threads will have any new <xref:System.Globalization.CultureInfo> property values.
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="Clone">
<MemberSignature Language="C#" Value="public virtual object Clone ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance object Clone() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Globalization.CultureInfo.Clone" />
<MemberSignature Language="VB.NET" Value="Public Overridable Function Clone () As Object" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; virtual System::Object ^ Clone();" />
<MemberSignature Language="F#" Value="abstract member Clone : unit -&gt; obj&#xA;override this.Clone : unit -&gt; obj" Usage="cultureInfo.Clone " />
<MemberType>Method</MemberType>
<Implements>
<InterfaceMember>M:System.ICloneable.Clone</InterfaceMember>
</Implements>
<AssemblyInfo>
<AssemblyName>System.Globalization</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime</AssemblyName>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName>System.Security.SecuritySafeCritical</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Object</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<summary>Creates a copy of the current <see cref="T:System.Globalization.CultureInfo" />.</summary>
<returns>A copy of the current <see cref="T:System.Globalization.CultureInfo" />.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The clone is writable even if the original <xref:System.Globalization.CultureInfo> is read-only. Therefore, the properties of the clone can be modified.
A shallow copy of an object is a copy of the object only. If the object contains references to other objects, the shallow copy does not create copies of the referred objects. It refers to the original objects instead. In contrast, a deep copy of an object creates a copy of the object and a copy of everything directly or indirectly referenced by that object.
The <xref:System.Globalization.CultureInfo.Clone%2A> method creates an enhanced shallow copy. The objects returned by the <xref:System.Globalization.CultureInfo.NumberFormat%2A>, <xref:System.Globalization.CultureInfo.DateTimeFormat%2A>, <xref:System.Globalization.CultureInfo.TextInfo%2A>, and <xref:System.Globalization.CultureInfo.Calendar%2A> properties are also copied. Consequently, the cloned <xref:System.Globalization.CultureInfo> object can modify its copied properties without affecting the original <xref:System.Globalization.CultureInfo> object.
## Examples
The following code example shows that CultureInfo.Clone also clones the <xref:System.Globalization.DateTimeFormatInfo> and <xref:System.Globalization.NumberFormatInfo> instances associated with the <xref:System.Globalization.CultureInfo>.
[!code-cpp[System.Globalization.CultureInfo.Clone#1](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.Clone/CPP/yslin_cultureinfo_clone.cpp#1)]
[!code-csharp[System.Globalization.CultureInfo.Clone#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.Clone/CS/yslin_cultureinfo_clone.cs#1)]
[!code-vb[System.Globalization.CultureInfo.Clone#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CultureInfo.Clone/VB/yslin_cultureinfo_clone.vb#1)]
]]></format>
</remarks>
<altmember cref="T:System.Object" />
</Docs>
</Member>
<Member MemberName="CompareInfo">
<MemberSignature Language="C#" Value="public virtual System.Globalization.CompareInfo CompareInfo { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance class System.Globalization.CompareInfo CompareInfo" />
<MemberSignature Language="DocId" Value="P:System.Globalization.CultureInfo.CompareInfo" />
<MemberSignature Language="VB.NET" Value="Public Overridable ReadOnly Property CompareInfo As CompareInfo" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; virtual property System::Globalization::CompareInfo ^ CompareInfo { System::Globalization::CompareInfo ^ get(); };" />
<MemberSignature Language="F#" Value="member this.CompareInfo : System.Globalization.CompareInfo" Usage="System.Globalization.CultureInfo.CompareInfo" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Globalization</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime</AssemblyName>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Globalization.CompareInfo</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets the <see cref="T:System.Globalization.CompareInfo" /> that defines how to compare strings for the culture.</summary>
<value>The <see cref="T:System.Globalization.CompareInfo" /> that defines how to compare strings for the culture.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Globalization.CultureInfo.CompareInfo%2A> property returns a <xref:System.Globalization.CompareInfo> object that provides culture-specific information used in culture-sensitive sorting and string comparison operations.
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 <xref:System.Globalization.CultureInfo.UseUserOverride%2A> is `true` and the specified culture matches the current culture of Windows, the <xref:System.Globalization.CultureInfo> uses those overrides, including user settings for the properties of the <xref:System.Globalization.DateTimeFormatInfo> instance returned by the <xref:System.Globalization.CultureInfo.DateTimeFormat%2A> property, and the properties of the <xref:System.Globalization.NumberFormatInfo> instance returned by the <xref:System.Globalization.CultureInfo.NumberFormat%2A> property. If the user settings are incompatible with the culture associated with the <xref:System.Globalization.CultureInfo>, for example, if the selected calendar is not one of the <xref:System.Globalization.CultureInfo.OptionalCalendars%2A>, the results of the methods and the values of the properties are undefined.
## Examples
The following code example shows how to create a <xref:System.Globalization.CultureInfo> for Spanish (Spain) with the international sort and another <xref:System.Globalization.CultureInfo> with the traditional sort.
[!code-cpp[System.Globalization.CultureInfo_esES#1](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo_esES/CPP/spanishspain.cpp#1)]
[!code-csharp[System.Globalization.CultureInfo_esES#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Globalization.CultureInfo_esES/CS/spanishspain.cs#1)]
[!code-vb[System.Globalization.CultureInfo_esES#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CultureInfo_esES/VB/spanishspain.vb#1)]
]]></format>
</remarks>
<altmember cref="T:System.Globalization.CompareInfo" />
</Docs>
</Member>
<Member MemberName="CreateSpecificCulture">
<MemberSignature Language="C#" Value="public static System.Globalization.CultureInfo CreateSpecificCulture (string name);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig class System.Globalization.CultureInfo CreateSpecificCulture(string name) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Globalization.CultureInfo.CreateSpecificCulture(System.String)" />
<MemberSignature Language="VB.NET" Value="Public Shared Function CreateSpecificCulture (name As String) As CultureInfo" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; static System::Globalization::CultureInfo ^ CreateSpecificCulture(System::String ^ name);" />
<MemberSignature Language="F#" Value="static member CreateSpecificCulture : string -&gt; System.Globalization.CultureInfo" Usage="System.Globalization.CultureInfo.CreateSpecificCulture name" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime</AssemblyName>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Globalization</AssemblyName>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Globalization.CultureInfo</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="name" Type="System.String" Index="0" FrameworkAlternate="netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netframework-1.1;netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netstandard-2.0;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netstandard-2.1" />
</Parameters>
<Docs>
<param name="name">A predefined <see cref="T:System.Globalization.CultureInfo" /> name or the name of an existing <see cref="T:System.Globalization.CultureInfo" /> object. <paramref name="name" /> is not case-sensitive.</param>
<summary>Creates a <see cref="T:System.Globalization.CultureInfo" /> that represents the specific culture that is associated with the specified name.</summary>
<returns>A <see cref="T:System.Globalization.CultureInfo" /> object that represents:
The invariant culture, if <paramref name="name" /> is an empty string ("").
-or-
The specific culture associated with <paramref name="name" />, if <paramref name="name" /> is a neutral culture.
-or-
The culture specified by <paramref name="name" />, if <paramref name="name" /> is already a specific culture.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Globalization.CultureInfo.CreateSpecificCulture%2A> method wraps a call to the <xref:System.Globalization.CultureInfo.%23ctor%28System.String%29> constructor.
> [!NOTE]
> For a list of predefined culture names on Windows systems, see the **Language tag** column in the [list of language/region names supported by Windows](https://docs.microsoft.com/openspecs/windows_protocols/ms-lcid/a9eac961-e77d-41a6-90a5-ce1a8b0cdb9c). Culture names follow the standard defined by [BCP 47](https://tools.ietf.org/html/bcp47). In addition, starting with Windows 10, `name` can be any valid BCP-47 language tag.
Cultures are grouped into three sets: the invariant culture, the neutral cultures, and the specific cultures. For more information, see the description of the <xref:System.Globalization.CultureInfo> class.
If the culture identifier of the specific culture returned by this method matches the culture identifier of the current Windows culture, this method creates a <xref:System.Globalization.CultureInfo> object that uses the Windows culture overrides. The overrides include user settings for the properties of the <xref:System.Globalization.DateTimeFormatInfo> object returned by the <xref:System.Globalization.CultureInfo.DateTimeFormat%2A> property and the <xref:System.Globalization.NumberFormatInfo> object returned by the <xref:System.Globalization.CultureInfo.NumberFormat%2A> property. To instantiate a <xref:System.Globalization.CultureInfo> object that with default culture settings rather than user overrides, call the <xref:System.Globalization.CultureInfo.%23ctor%28System.String%2CSystem.Boolean%29> constructor with a value of `false` for the `useUserOverride` argument.
Although the <xref:System.Globalization.CultureInfo.CreateSpecificCulture%2A> method name includes the term "Specific", remember that culture data can change between versions, or due to custom cultures, or because of user overrides. Use the invariant culture or binary or fixed forms for saving data.
## Examples
The following example retrieves an array of <xref:System.Globalization.CultureInfo> objects that represent neutral cultures from the <xref:System.Globalization.CultureInfo.GetCultures%2A> method and sorts the array. When it iterates the elements in the array, it passes the name of each neutral culture to the <xref:System.Globalization.CultureInfo.CreateSpecificCulture%2A> method and displays the name of the specific culture returned by the method.
> [!NOTE]
> The example uses the zh-CHS and zh-CHT culture names. However, applications that target Windows Vista and later should use zh-Hans instead of zh-CHS and zh-Hant instead of zh-CHT. zh-Hans and zh-Hant represent the current standard and should be used unless you have a reason for using the older names.
>
> Note also that the results of the example may differ on an installation of Taiwanese Windows, where the input of a Chinese (Traditional) neutral culture (zh, zh-CHT, or zh-Hant) will return zh-TW.
[!code-csharp[System.Globalization.CultureInfo.CreateSpecificCulture2#2](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.CreateSpecificCulture2/CS/createspecificculture2.cs#2)]
[!code-vb[System.Globalization.CultureInfo.CreateSpecificCulture2#2](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CultureInfo.CreateSpecificCulture2/VB/createspecificculture2.vb#2)]
]]></format>
</remarks>
<exception cref="T:System.Globalization.CultureNotFoundException">
<paramref name="name" /> is not a valid culture name.
-or-
The culture specified by <paramref name="name" /> does not have a specific culture associated with it.</exception>
<exception cref="T:System.NullReferenceException">
<paramref name="name" /> is null.</exception>
<block subset="none" type="usage">
<para>The [!INCLUDE[net_v35_long](~/includes/net-v35-long-md.md)] and earlier versions throw an <see cref="T:System.ArgumentException" /> if <paramref name="name" /> is not a valid culture name. Starting with the [!INCLUDE[net_v40_long](~/includes/net-v40-long-md.md)], this method throws a <see cref="T:System.Globalization.CultureNotFoundException" />.</para>
</block>
<altmember cref="Overload:System.Globalization.CultureInfo.#ctor" />
<altmember cref="P:System.Globalization.CultureInfo.Parent" />
</Docs>
</Member>
<Member MemberName="CultureTypes">
<MemberSignature Language="C#" Value="public System.Globalization.CultureTypes CultureTypes { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance valuetype System.Globalization.CultureTypes CultureTypes" />
<MemberSignature Language="DocId" Value="P:System.Globalization.CultureInfo.CultureTypes" />
<MemberSignature Language="VB.NET" Value="Public ReadOnly Property CultureTypes As CultureTypes" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; property System::Globalization::CultureTypes CultureTypes { System::Globalization::CultureTypes get(); };" />
<MemberSignature Language="F#" Value="member this.CultureTypes : System.Globalization.CultureTypes" Usage="System.Globalization.CultureInfo.CultureTypes" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime</AssemblyName>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Globalization</AssemblyName>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netframework-4.8">
<AttributeName>System.Runtime.InteropServices.ComVisible(false)</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Globalization.CultureTypes</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets the culture types that pertain to the current <see cref="T:System.Globalization.CultureInfo" /> object.</summary>
<value>A bitwise combination of one or more <see cref="T:System.Globalization.CultureTypes" /> values. There is no default value.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Examples
The following example demonstrates the <xref:System.Globalization.CultureTypes> enumeration and the <xref:System.Globalization.CultureInfo.CultureTypes%2A> property.
[!code-csharp[system.globalization.cultureTypes#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.globalization.cultureTypes/cs/ct.cs#1)]
[!code-vb[system.globalization.cultureTypes#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.cultureTypes/vb/ct.vb#1)]
]]></format>
</remarks>
<altmember cref="T:System.Globalization.CultureTypes" />
</Docs>
</Member>
<Member MemberName="CurrentCulture">
<MemberSignature Language="C#" Value="public static System.Globalization.CultureInfo CurrentCulture { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property class System.Globalization.CultureInfo CurrentCulture" />
<MemberSignature Language="DocId" Value="P:System.Globalization.CultureInfo.CurrentCulture" />
<MemberSignature Language="VB.NET" Value="Public Shared Property CurrentCulture As CultureInfo" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; static property System::Globalization::CultureInfo ^ CurrentCulture { System::Globalization::CultureInfo ^ get(); void set(System::Globalization::CultureInfo ^ value); };" />
<MemberSignature Language="F#" Value="member this.CurrentCulture : System.Globalization.CultureInfo with get, set" Usage="System.Globalization.CultureInfo.CurrentCulture" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Globalization</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime</AssemblyName>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2">
<AttributeName>get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Globalization.CultureInfo</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets the <see cref="T:System.Globalization.CultureInfo" /> object that represents the culture used by the current thread.</summary>
<value>An object that represents the culture used by the current thread.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Globalization.CultureInfo> object that is returned by this property and its associated objects determine the default format for dates, times, numbers, currency values, the sorting order of text, casing conventions, and string comparisons.
The current culture is a property of the executing thread. Retrieving the value of the <xref:System.Globalization.CultureInfo.CurrentCulture%2A?displayProperty=nameWithType> property is a more performant equivalent of retrieving the <xref:System.Globalization.CultureInfo> object returned by the `Thread.CurrentThread.CurrentCulture` property.
> [!NOTE]
> In the .NET Framework 4.5.2 and earlier versions, the <xref:System.Globalization.CultureInfo.CurrentCulture%2A> property is read-only; that is, you can retrieve the property value, but you cannot set it. To change the current culture, you assign the <xref:System.Globalization.CultureInfo> object that represents the new culture to the `Thread.CurrentThread.CurrentCulture` property. Starting with the [!INCLUDE[net_v46](~/includes/net-v46-md.md)], the <xref:System.Globalization.CultureInfo.CurrentCulture%2A> property is read-write; you can both set and retrieve the property's value. If you do set the property value to a <xref:System.Globalization.CultureInfo> object that represents a new culture, the value of the `Thread.CurrentThread.CurrentCulture` property also changes.
In this section:
[How a Thread's Culture Is Determined](#ThreadCulture)
[Getting the Current Culture](#Getting)
[Explicitly Setting the CurrentCulture Property](#ExplicitSetting)
[The Current Culture and User Overrides](#Overrides)
[Culture and Windows Apps](#WindowsAndCurr)
<a name="ThreadCulture"></a>
## How a Thread's Culture Is Determined
When a thread is started, its culture is initially determined as follows:
- By retrieving the culture that is specified by the <xref:System.Globalization.CultureInfo.DefaultThreadCurrentCulture%2A> property in the application domain in which the thread is executing, if the property value is not `null`.
- If the thread is a thread pool thread that is executing a task-based asynchronous operation and the app targets the [!INCLUDE[net_v46](~/includes/net-v46-md.md)] or a later version of the .NET Framework, its culture is determined by the culture of the calling thread. The following example changes the current culture to Portuguese (Brazil) and launches six tasks, each of which displays its thread ID, its task ID, and its current culture. Each of the tasks (and the threads) has inherited the culture of the calling thread.
[!code-csharp[System.Globalization.CultureInfo.CurrentCulture#14](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.globalization.cultureinfo.currentculture/cs/Async1.cs#14)]
[!code-vb[System.Globalization.CultureInfo.CurrentCulture#14](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.cultureinfo.currentculture/vb/Async1.vb#14)]
For more information, see the "Culture and task-based asynchronous operations" section in the <xref:System.Globalization.CultureInfo> topic.
- By calling the Windows `GetUserDefaultLocaleName` function.
Note that if you set a specific culture that is different from the system-installed culture or the user's preferred culture, and your application starts multiple threads, the current culture of those threads will be the culture that is returned by the `GetUserDefaultLocaleName` function, unless you assign a culture to the <xref:System.Globalization.CultureInfo.DefaultThreadCurrentCulture%2A> property in the application domain in which the thread is executing.
For more information about how the culture of a thread is determined, see the "Culture and threads" section in the <xref:System.Globalization.CultureInfo> reference page.
<a name="Getting"></a>
## Getting the Current Culture
The <xref:System.Globalization.CultureInfo.CurrentCulture%2A?displayProperty=nameWithType> property is a per-thread setting; that is, each thread can have its own culture. You get the culture of the current thread by retrieving the value of the <xref:System.Globalization.CultureInfo.CurrentCulture%2A?displayProperty=nameWithType> property, as the following example illustrates.
[!code-csharp[System.Globalization.CultureInfo.CurrentCulture#5](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.globalization.cultureinfo.currentculture/cs/Get1.cs#5)]
[!code-vb[System.Globalization.CultureInfo.CurrentCulture#5](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.cultureinfo.currentculture/vb/Get1.vb#5)]
You can also retrieve the value of the current thread's culture from the <xref:System.Threading.Thread.CurrentThread%2A?displayProperty=nameWithType> property.
<a name="ExplicitSetting"></a>
## Explicitly Setting the CurrentCulture Property
Staring with the [!INCLUDE[net_v46](~/includes/net-v46-md.md)], to change the culture that is used by an existing thread, you set the <xref:System.Globalization.CultureInfo.CurrentCulture%2A?displayProperty=nameWithType> property to the new culture. If you explicitly change a thread's culture in this way, that change persists if the thread crosses application domain boundaries. The following example changes the current thread culture to Dutch (Netherlands). It also shows that, when the current thread crosses application domain boundaries, its current culture remains changed.
[!code-csharp[System.Globalization.CultureInfo.CurrentCulture#11](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.globalization.cultureinfo.currentculture/cs/changeculture11.cs#11)]
[!code-vb[System.Globalization.CultureInfo.CurrentCulture#11](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.cultureinfo.currentculture/vb/changeculture11.vb#11)]
> [!NOTE]
> Changing the culture by using the <xref:System.Globalization.CultureInfo.CurrentCulture%2A?displayProperty=nameWithType> property requires a <xref:System.Security.Permissions.SecurityPermission> permission with the <xref:System.Security.Permissions.SecurityPermissionFlag.ControlThread> value set. Manipulating threads is dangerous because of the security state associated with threads. Therefore, this permission should be given only to trustworthy code, and then only as necessary. You cannot change thread culture in semi-trusted code.
Starting with the [!INCLUDE[net_v40_short](~/includes/net-v40-short-md.md)], you can explicitly change the current thread culture to either a specific culture (such as French (Canada)) or a neutral culture (such as French). When a <xref:System.Globalization.CultureInfo> object represents a neutral culture, the values of <xref:System.Globalization.CultureInfo> properties such as <xref:System.Globalization.CultureInfo.Calendar%2A>, <xref:System.Globalization.CultureInfo.CompareInfo%2A>, <xref:System.Globalization.CultureInfo.DateTimeFormat%2A>, <xref:System.Globalization.CultureInfo.NumberFormat%2A>, and <xref:System.Globalization.CultureInfo.TextInfo%2A> reflect the specific culture that is associated with the neutral culture. For example, the dominant culture for the English neutral culture is English (United States); the dominant culture for the German culture is German (Germany). The following example illustrates the difference in formatting when the current culture is set to a specific culture, French (Canada), and a neutral culture, French.
[!code-csharp[System.Globalization.CultureInfo.CurrentCulture#12](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.globalization.cultureinfo.currentculture/cs/specific12.cs#12)]
[!code-vb[System.Globalization.CultureInfo.CurrentCulture#12](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.cultureinfo.currentculture/vb/specific12.vb#12)]
You can also use the <xref:System.Globalization.CultureInfo.CurrentCulture%2A?displayProperty=nameWithType> property along with the <xref:System.Web.HttpRequest.UserLanguages%2A?displayProperty=nameWithType> property to set the <xref:System.Globalization.CultureInfo.CurrentCulture%2A> property of an ASP.NET application to the user's preferred culture, as the following example illustrates.
[!code-csharp[System.Globalization.CultureInfo.CurrentCulture#13](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.globalization.cultureinfo.currentculture/cs/aspculture13.cs#13)]
[!code-vb[System.Globalization.CultureInfo.CurrentCulture#13](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.cultureinfo.currentculture/vb/aspculture13.vb#13)]
<a name="Overrides"></a>
## The Current Culture and User Overrides
Windows allows users to override the standard property values of the <xref:System.Globalization.CultureInfo> object and its associated objects by using **Regional and Language Options** in Control Panel. The <xref:System.Globalization.CultureInfo> object returned by the <xref:System.Globalization.CultureInfo.CurrentCulture%2A> property reflects these user overrides in the following cases:
- If the current thread culture is set implicitly by the Windows `GetUserDefaultLocaleName` function.
- If the current thread culture defined by the <xref:System.Globalization.CultureInfo.DefaultThreadCurrentCulture%2A> property corresponds to the current Windows system culture.
- If the current thread culture is set explicitly to a culture returned by the <xref:System.Globalization.CultureInfo.CreateSpecificCulture%2A> method, and that culture corresponds to the current Windows system culture.
- If the current thread culture is set explicitly to a culture instantiated by the <xref:System.Globalization.CultureInfo.%23ctor%28System.String%29> constructor, and that culture corresponds to the current Windows system culture.
In some cases, particularly for server applications, setting the current culture to a <xref:System.Globalization.CultureInfo> object that reflects user overrides may be undesirable. Instead, you can set the current thread culture to a <xref:System.Globalization.CultureInfo> object that does not reflect user overrides in the following ways:
- By calling the <xref:System.Globalization.CultureInfo.%23ctor%28System.String%2CSystem.Boolean%29> constructor with a value of `false` for the `useUserOverride` argument.
- By calling the <xref:System.Globalization.CultureInfo.GetCultureInfo%2A> method, which returns a cached, read-only <xref:System.Globalization.CultureInfo> object.
<a name="WindowsAndCurr"></a>
## The current culture and UWP apps
In Universal Windows Platform (UWP) apps, the <xref:System.Globalization.CultureInfo.CurrentCulture%2A> property is read-write, just as it is in .NET Framework and .NET Core apps; you can use it both to get and to set the current culture. However, UWP apps do not distinguish between the current culture and the current UI culture. The <xref:System.Globalization.CultureInfo.CurrentCulture%2A> and <xref:System.Globalization.CultureInfo.CurrentUICulture%2A> properties map to the first value in the [Windows.ApplicationModel.Resources.Core.ResourceManager.DefaultContext.Languages](https://docs.microsoft.com/uwp/api/windows.applicationmodel.resources.core.resourcecontext#properties_) collection.
In .NET Framework and .NET Core apps, the current culture is a per-thread setting, and the <xref:System.Globalization.CultureInfo.CurrentCulture%2A> property reflects the culture of the current thread only. In UWP apps, the current culture maps to the [Windows.ApplicationModel.Resources.Core.ResourceManager.DefaultContext.Languages](https://docs.microsoft.com/uwp/api/windows.applicationmodel.resources.core.resourcecontext#properties_) property, which is a global setting. Setting the <xref:System.Globalization.CultureInfo.CurrentCulture%2A> property changes the culture of the entire app; culture cannot be set on a per-thread basis.
## Examples
The following example demonstrates how to change the <xref:System.Globalization.CultureInfo.CurrentCulture%2A> and <xref:System.Globalization.CultureInfo.CurrentUICulture%2A> of the current thread.
[!code-cpp[System.Globalization.CultureInfo.CurrentCulture2#11](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.CurrentCulture2/CPP/currentculture.cpp#11)]
[!code-csharp[System.Globalization.CultureInfo.CurrentCulture2#11](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.CurrentCulture2/CS/currentculture.cs#11)]
[!code-vb[System.Globalization.CultureInfo.CurrentCulture2#11](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CultureInfo.CurrentCulture2/VB/currentculture.vb#11)]
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">The property is set to <see langword="null" />.</exception>
<permission cref="T:System.Security.Permissions.SecurityPermission">for setting the current culture. Associated enumeration: <see cref="F:System.Security.Permissions.SecurityPermissionFlag.ControlThread" /></permission>
<altmember cref="P:System.Globalization.CultureInfo.DefaultThreadCurrentCulture" />
<altmember cref="P:System.Threading.Thread.CurrentCulture" />
<altmember cref="P:System.Globalization.CultureInfo.CurrentUICulture" />
<altmember cref="P:System.Globalization.CultureInfo.InstalledUICulture" />
<altmember cref="P:System.Globalization.CultureInfo.InvariantCulture" />
<altmember cref="P:System.Globalization.CultureInfo.Parent" />
<altmember cref="T:System.Security.Permissions.SecurityPermission" />
<altmember cref="T:System.Security.Permissions.SecurityPermissionAttribute" />
</Docs>
</Member>
<Member MemberName="CurrentUICulture">
<MemberSignature Language="C#" Value="public static System.Globalization.CultureInfo CurrentUICulture { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property class System.Globalization.CultureInfo CurrentUICulture" />
<MemberSignature Language="DocId" Value="P:System.Globalization.CultureInfo.CurrentUICulture" />
<MemberSignature Language="VB.NET" Value="Public Shared Property CurrentUICulture As CultureInfo" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; static property System::Globalization::CultureInfo ^ CurrentUICulture { System::Globalization::CultureInfo ^ get(); void set(System::Globalization::CultureInfo ^ value); };" />
<MemberSignature Language="F#" Value="member this.CurrentUICulture : System.Globalization.CultureInfo with get, set" Usage="System.Globalization.CultureInfo.CurrentUICulture" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Globalization</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime</AssemblyName>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2">
<AttributeName>get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Globalization.CultureInfo</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets the <see cref="T:System.Globalization.CultureInfo" /> object that represents the current user interface culture used by the Resource Manager to look up culture-specific resources at run time.</summary>
<value>The culture used by the Resource Manager to look up culture-specific resources at run time.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The current UI culture is a per-thread property. That is, each thread has its own current UI culture. This property is equivalent to retrieving or, starting with the [!INCLUDE[net_v46](~/includes/net-v46-md.md)], setting the <xref:System.Globalization.CultureInfo> object assigned to the `System.Threading.Thread.CurrentThread.CurrentUICulture` property. When a thread is started, its UI culture is initially determined as follows:
- By retrieving the culture that is specified by the <xref:System.Globalization.CultureInfo.DefaultThreadCurrentUICulture%2A> property in the application domain in which the thread is executing, if the property value is not `null`.
- If the thread is a thread pool thread that is executing a task-based asynchronous operation and the app targets the [!INCLUDE[net_v46](~/includes/net-v46-md.md)] or a later version of the .NET Framework, its UI culture is determined by the UI culture of the calling thread. The following example changes the current UI culture to Portuguese (Brazil) and launches six tasks, each of which displays its thread ID, its task ID, and its current UI culture. Each of the tasks (and the threads) has inherited the UI culture of the calling thread.
[!code-csharp[System.Globalization.CultureInfo.CurrentUICulture#14](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.globalization.cultureinfo.currentuiculture/cs/Async1.cs#14)]
[!code-vb[System.Globalization.CultureInfo.CurrentUICulture#14](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.cultureinfo.currentuiculture/vb/Async1.vb#14)]
For more information, see the "Culture and task-based asynchronous operations" section in the <xref:System.Globalization.CultureInfo> topic.
- By calling the Windows `GetUserDefaultUILanguage` function.
> [!NOTE]
> In the [!INCLUDE[Compact](~/includes/compact-md.md)], the <xref:System.Globalization.CultureInfo.CurrentUICulture%2A> property is read-only. The current UI culture is determined by the system's regional settings and cannot be changed programmatically.
Starting with the [!INCLUDE[net_v46](~/includes/net-v46-md.md)], to change the user interface culture used by a thread, set the <xref:System.Threading.Thread.CurrentUICulture%2A?displayProperty=nameWithType> property to the new culture. If you explicitly change a thread's UI culture in this way, that change persists if the thread crosses application domain boundaries.
> [!NOTE]
> In the .NET Framework 4.5.2 and earlier versions, the <xref:System.Globalization.CultureInfo.CurrentUICulture%2A> property is read-only; that is, you can retrieve the property value, but you cannot set it. To change the current UI culture, you assign the <xref:System.Globalization.CultureInfo> object that represents the new UI culture to the `Thread.CurrentThread.CurrentUICulture` property. Starting with the [!INCLUDE[net_v46](~/includes/net-v46-md.md)], the <xref:System.Globalization.CultureInfo.CurrentUICulture%2A?displayProperty=nameWithType> property is read-write; you can both set and retrieve the property's value. If you do set the property value to a <xref:System.Globalization.CultureInfo> object that represents a new culture, the value of the `Thread.CurrentThread.CurrentCulture` property also changes.
In this section:
[Getting the Current UI Culture](#Getting)
[Explicitly Setting the Current UI Culture](#Explicit)
[Implicitly Setting the Current UI Culture](#Implicit)
[Security Considerations](#Security)
[The Current UI Culture and Windows apps](#WindowsAndCurrUI)
<a name="Getting"></a>
## Getting the Current UI Culture
The <xref:System.Globalization.CultureInfo.CurrentUICulture%2A?displayProperty=nameWithType> property is a per-thread setting; that is, each thread can have its own UI culture. You get the UI culture of the current thread by retrieving the value of the <xref:System.Globalization.CultureInfo.CurrentUICulture%2A?displayProperty=nameWithType> property, as the following example illustrates.
[!code-csharp[System.Globalization.CultureInfo.CurrentUICulture#5](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.globalization.cultureinfo.currentuiculture/cs/Get1.cs#5)]
[!code-vb[System.Globalization.CultureInfo.CurrentUICulture#5](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.cultureinfo.currentuiculture/vb/Get1.vb#5)]
You can also retrieve the value of the current thread's UI culture from the <xref:System.Threading.Thread.CurrentUICulture%2A?displayProperty=nameWithType> property.
<a name="Explicit"></a>
## Explicitly Setting the Current UI Culture
Starting with the [!INCLUDE[net_v46](~/includes/net-v46-md.md)], you can change the current UI culture by assigning a <xref:System.Globalization.CultureInfo> object that represents the new culture to the <xref:System.Globalization.CultureInfo.CurrentUICulture%2A?displayProperty=nameWithType> property. The current UI culture can be set to either a specific culture (such as en-US or de-DE) or to a neutral culture (such as en or de). The following example sets the current UI culture to fr-FR or French (France).
[!code-csharp[System.Globalization.CultureInfo.CurrentUICulture#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.globalization.cultureinfo.currentuiculture/cs/currentuiculture1.cs#1)]
[!code-vb[System.Globalization.CultureInfo.CurrentUICulture#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.cultureinfo.currentuiculture/vb/currentuiculture1.vb#1)]
In a multithreaded application, you can explicitly set the UI culture of any thread by assigning a <xref:System.Globalization.CultureInfo> object that represents that culture to the thread's <xref:System.Threading.Thread.CurrentUICulture%2A?displayProperty=nameWithType> property. If the thread whose culture you want to set is the current thread, you can assign the new culture to the <xref:System.Globalization.CultureInfo.CurrentUICulture%2A?displayProperty=nameWithType> property. When the UI culture of a thread is set explicitly, that thread retains the same culture even if it crosses application domain boundaries and executes code in another application domain.
<a name="Implicit"></a>
## Implicitly Setting the Current UI Culture
When a thread, including the main application thread, is first created, by default its current UI culture is set as follows:
- By using the culture defined by the <xref:System.Globalization.CultureInfo.DefaultThreadCurrentUICulture%2A> property for the current application domain if the property value is not `null`.
- By using the system's default culture. On systems that use the Windows operating system, the common language runtime calls the Windows `GetUserDefaultUILanguage` function to set the current UI culture. `GetUserDefaultUILanguage` returns the default UI culture set by the user. If the user has not set a default UI language, it returns the culture originally installed on the system.
If the thread crosses application boundaries and executes code in another application domain, its culture is determined in the same way as that of a newly created thread.
Note that if you set a specific UI culture that is different from the system-installed UI culture or the user's preferred UI culture, and your application starts multiple threads, the current UI culture of those threads will be the culture returned by the `GetUserDefaultUILanguage` function, unless you assign a culture to the <xref:System.Globalization.CultureInfo.DefaultThreadCurrentUICulture%2A> property in the application domain in which the thread is executing.
<a name="Security"></a>
## Security Considerations
Changing the culture of the current thread requires a <xref:System.Security.Permissions.SecurityPermission> permission with the <xref:System.Security.Permissions.SecurityPermissionFlag.ControlThread> value set.
> [!CAUTION]
> Manipulating threads is dangerous because of the security state associated with threads. Therefore, this permission should be given only to trustworthy code, and then only as necessary. You cannot change thread culture in semi-trusted code.
<a name="WindowsAndCurrUI"></a>
## The current UI culture and UWP apps
In Universal Windows Platform (UWP) apps, the <xref:System.Globalization.CultureInfo.CurrentUICulture%2A> property is read-write, just as it is in .NET Framework and .NET Core apps; you can use it both to get and to set the current culture. However, UWP apps do not distinguish between the current culture and the current UI culture. The <xref:System.Globalization.CultureInfo.CurrentCulture%2A> and <xref:System.Globalization.CultureInfo.CurrentUICulture%2A> properties map to the first value in the [Windows.ApplicationModel.Resources.Core.ResourceManager.DefaultContext.Languages](https://docs.microsoft.com/uwp/api/windows.applicationmodel.resources.core.resourcecontext#properties_) collection.
In .NET Framework and .NET Core apps, the current UI culture is a per-thread setting, and the <xref:System.Globalization.CultureInfo.CurrentUICulture%2A> property reflects the UI culture of the current thread only. In UWP apps, the current culture maps to the [Windows.ApplicationModel.Resources.Core.ResourceManager.DefaultContext.Languages](https://docs.microsoft.com/uwp/api/windows.applicationmodel.resources.core.resourcecontext#properties_) property, which is a global setting. Setting the <xref:System.Globalization.CultureInfo.CurrentCulture%2A> property changes the culture of the entire app; culture cannot be set on a per-thread basis.
## Examples
The following code example demonstrates how to change the <xref:System.Globalization.CultureInfo.CurrentCulture%2A> and <xref:System.Globalization.CultureInfo.CurrentUICulture%2A> of the current thread.
[!code-cpp[System.Globalization.CultureInfo.CurrentCulture2#11](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.CurrentCulture2/CPP/currentculture.cpp#11)]
[!code-csharp[System.Globalization.CultureInfo.CurrentCulture2#11](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.CurrentCulture2/CS/currentculture.cs#11)]
[!code-vb[System.Globalization.CultureInfo.CurrentCulture2#11](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CultureInfo.CurrentCulture2/VB/currentculture.vb#11)]
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">The property is set to <see langword="null" />.</exception>
<exception cref="T:System.ArgumentException">The property is set to a culture name that cannot be used to locate a resource file. Resource filenames can include only letters, numbers, hyphens, or underscores.</exception>
<permission cref="T:System.Security.Permissions.SecurityPermission">for setting the current UI culture. Associated enumeration: <see cref="F:System.Security.Permissions.SecurityPermissionFlag.ControlThread" /></permission>
<altmember cref="T:System.Resources.ResourceManager" />
<altmember cref="P:System.Threading.Thread.CurrentUICulture" />
<altmember cref="P:System.Globalization.CultureInfo.CurrentCulture" />
<altmember cref="P:System.Globalization.CultureInfo.InstalledUICulture" />
<altmember cref="P:System.Globalization.CultureInfo.DefaultThreadCurrentUICulture" />
</Docs>
</Member>
<Member MemberName="DateTimeFormat">
<MemberSignature Language="C#" Value="public virtual System.Globalization.DateTimeFormatInfo DateTimeFormat { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance class System.Globalization.DateTimeFormatInfo DateTimeFormat" />
<MemberSignature Language="DocId" Value="P:System.Globalization.CultureInfo.DateTimeFormat" />
<MemberSignature Language="VB.NET" Value="Public Overridable Property DateTimeFormat As DateTimeFormatInfo" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; virtual property System::Globalization::DateTimeFormatInfo ^ DateTimeFormat { System::Globalization::DateTimeFormatInfo ^ get(); void set(System::Globalization::DateTimeFormatInfo ^ value); };" />
<MemberSignature Language="F#" Value="member this.DateTimeFormat : System.Globalization.DateTimeFormatInfo with get, set" Usage="System.Globalization.CultureInfo.DateTimeFormat" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Globalization</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime</AssemblyName>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName>get: System.Security.SecuritySafeCritical</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Globalization.DateTimeFormatInfo</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets a <see cref="T:System.Globalization.DateTimeFormatInfo" /> that defines the culturally appropriate format of displaying dates and times.</summary>
<value>A <see cref="T:System.Globalization.DateTimeFormatInfo" /> that defines the culturally appropriate format of displaying dates and times.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
## Overrides
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 <xref:System.Globalization.CultureInfo.UseUserOverride%2A> is `true` and the specified culture matches the current culture of Windows, the <xref:System.Globalization.CultureInfo> uses those overrides, including user settings for the properties of the <xref:System.Globalization.DateTimeFormatInfo> instance returned by the <xref:System.Globalization.CultureInfo.DateTimeFormat%2A> property, and the properties of the <xref:System.Globalization.NumberFormatInfo> instance returned by the <xref:System.Globalization.CultureInfo.NumberFormat%2A> property. If the user settings are incompatible with the culture associated with the <xref:System.Globalization.CultureInfo>, for example, if the selected calendar is not one of the <xref:System.Globalization.CultureInfo.OptionalCalendars%2A>, the results of the methods and the values of the properties are undefined.
The value of the <xref:System.Globalization.CultureInfo.DateTimeFormat%2A> property and the <xref:System.Globalization.CultureInfo.NumberFormat%2A> property is not calculated until your application accesses the property. If the user can change the current culture to a new culture while the application is running and then the application accesses the <xref:System.Globalization.CultureInfo.DateTimeFormat%2A> or <xref:System.Globalization.CultureInfo.NumberFormat%2A> property, the application retrieves the defaults for the new culture instead of the overrides for the original culture. To preserve the overrides for the original current culture, the application should access the <xref:System.Globalization.CultureInfo.DateTimeFormat%2A> and <xref:System.Globalization.CultureInfo.NumberFormat%2A> properties before changing the current culture.
## Examples
The following code example shows that CultureInfo.Clone also clones the <xref:System.Globalization.DateTimeFormatInfo> and <xref:System.Globalization.NumberFormatInfo> instances associated with the <xref:System.Globalization.CultureInfo>.
[!code-cpp[System.Globalization.CultureInfo.Clone#1](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.Clone/CPP/yslin_cultureinfo_clone.cpp#1)]
[!code-csharp[System.Globalization.CultureInfo.Clone#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.Clone/CS/yslin_cultureinfo_clone.cs#1)]
[!code-vb[System.Globalization.CultureInfo.Clone#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CultureInfo.Clone/VB/yslin_cultureinfo_clone.vb#1)]
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">The property is set to null.</exception>
<exception cref="T:System.InvalidOperationException">The <see cref="P:System.Globalization.CultureInfo.DateTimeFormat" /> property or any of the <see cref="T:System.Globalization.DateTimeFormatInfo" /> properties is set, and the <see cref="T:System.Globalization.CultureInfo" /> is read-only.</exception>
<block subset="none" type="usage">
<para>If <see cref="P:System.Globalization.DateTimeFormatInfo.Calendar" /> is the <see cref="T:System.Globalization.TaiwanCalendar" /> but the <see cref="P:System.Threading.Thread.CurrentCulture" /> is not set to Chinese (Taiwan), named zh-TW, then <see cref="P:System.Globalization.DateTimeFormatInfo.NativeCalendarName" />, <see cref="M:System.Globalization.DateTimeFormatInfo.GetEraName(System.Int32)" />, and <see cref="M:System.Globalization.DateTimeFormatInfo.GetAbbreviatedEraName(System.Int32)" /> return an empty string ("").</para>
</block>
<altmember cref="T:System.Globalization.DateTimeFormatInfo" />
<altmember cref="M:System.Globalization.CultureInfo.GetFormat(System.Type)" />
<altmember cref="P:System.Globalization.CultureInfo.NumberFormat" />
</Docs>
</Member>
<Member MemberName="DefaultThreadCurrentCulture">
<MemberSignature Language="C#" Value="public static System.Globalization.CultureInfo DefaultThreadCurrentCulture { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property class System.Globalization.CultureInfo DefaultThreadCurrentCulture" />
<MemberSignature Language="DocId" Value="P:System.Globalization.CultureInfo.DefaultThreadCurrentCulture" />
<MemberSignature Language="VB.NET" Value="Public Shared Property DefaultThreadCurrentCulture As CultureInfo" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; static property System::Globalization::CultureInfo ^ DefaultThreadCurrentCulture { System::Globalization::CultureInfo ^ get(); void set(System::Globalization::CultureInfo ^ value); };" />
<MemberSignature Language="F#" Value="member this.DefaultThreadCurrentCulture : System.Globalization.CultureInfo with get, set" Usage="System.Globalization.CultureInfo.DefaultThreadCurrentCulture" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Globalization</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime</AssemblyName>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netstandard-1.0;netstandard-1.1;netstandard-1.2;netframework-4.8">
<AttributeName>set: System.Security.SecuritySafeCritical</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Globalization.CultureInfo</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets the default culture for threads in the current application domain.</summary>
<value>The default culture for threads in the current application domain, or <see langword="null" /> if the current system culture is the default thread culture in the application domain.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
In the [!INCLUDE[net_v40_long](~/includes/net-v40-long-md.md)] and previous versions, by default, the culture of all threads is set to the Windows system culture. For applications whose current culture differs from the default system culture, this behavior is often undesirable. In the [!INCLUDE[net_v45](~/includes/net-v45-md.md)], the <xref:System.Globalization.CultureInfo.DefaultThreadCurrentCulture%2A> property enables an application to define the default culture of all threads in an application domain.
> [!IMPORTANT]
> If you have not explicitly set the culture of any existing threads executing in an application domain, setting the <xref:System.Globalization.CultureInfo.DefaultThreadCurrentCulture%2A> property also changes the culture of these threads. However, if these threads execute in another application domain, their culture is defined by the <xref:System.Globalization.CultureInfo.DefaultThreadCurrentCulture%2A> property in that application domain or, if no default value is defined, by the default system culture. Because of this, we recommend that you always explicitly set the culture of your main application thread, and not rely on the <xref:System.Globalization.CultureInfo.DefaultThreadCurrentCulture%2A> property to define the culture of the main application thread.
Unless it is set explicitly, the value of the <xref:System.Globalization.CultureInfo.DefaultThreadCurrentCulture%2A> property is `null`, and the culture of threads in an application domain that have not been assigned an explicit culture is defined by the default Windows system culture.
For more information about cultures, threads, and application domains, see the "Culture and threads" and "Culture and application domains" sections in the <xref:System.Globalization.CultureInfo> reference page.
## Examples
The following example illustrates the default behavior of the .NET Framework in defining the current culture of a new thread. At startup, the example sets the current culture and the current UI culture to French (France) on all systems except those on which the default system culture is already French (France). If the default system culture is already French (France), the code sets the current culture and the current UI culture to English (United States). It then calls the `DisplayRandomNumbers` routine, which generates three random numbers and displays them as currency values. Next, it creates a new thread, which also executes the `DisplayRandomNumbers` routine.
[!code-csharp[System.Globalization.CultureInfo.DefaultThreadCurrentCulture#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.globalization.cultureinfo.defaultthreadcurrentculture/cs/defaultculture1.cs#1)]
[!code-vb[System.Globalization.CultureInfo.DefaultThreadCurrentCulture#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.cultureinfo.defaultthreadcurrentculture/vb/defaultculture1.vb#1)]
As the output from the example shows, when the example is run on a computer whose system culture is English (United States), the main thread displays its currency values using the formatting conventions of the French (France) culture. However, because the worker thread's culture is derived from the current Windows system culture rather than the application's current culture, the work thread displays its currency values using the formatting conventions of the English (United States) culture.
The following example uses the <xref:System.Globalization.CultureInfo.DefaultThreadCurrentCulture%2A> and <xref:System.Globalization.CultureInfo.DefaultThreadCurrentUICulture%2A> properties to define the current culture and current UI culture of a new application thread. At startup, the example sets the current culture and the current UI culture to French (France) on all systems except those on which the default system culture is already French (France). If the default system culture is already French (France), it sets the current culture and the current UI culture to English (United States). It then calls the `DisplayRandomNumbers` routine, which generates three random numbers and displays them as currency values. Next, it creates a new thread, which also executes the `DisplayRandomNumbers` routine.
[!code-csharp[System.Globalization.CultureInfo.DefaultThreadCurrentCulture#2](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.globalization.cultureinfo.defaultthreadcurrentculture/cs/defaultculture2.cs#2)]
[!code-vb[System.Globalization.CultureInfo.DefaultThreadCurrentCulture#2](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.cultureinfo.defaultthreadcurrentculture/vb/defaultculture2.vb#2)]
As the output from the example shows, when the example is run on a computer whose system culture is English (United States), both the main thread and the worker thread display their currency values using the formatting conventions of the French (France) culture.
]]></format>
</remarks>
<altmember cref="P:System.Globalization.CultureInfo.CurrentCulture" />
<altmember cref="P:System.Globalization.CultureInfo.DefaultThreadCurrentUICulture" />
</Docs>
</Member>
<Member MemberName="DefaultThreadCurrentUICulture">
<MemberSignature Language="C#" Value="public static System.Globalization.CultureInfo DefaultThreadCurrentUICulture { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property class System.Globalization.CultureInfo DefaultThreadCurrentUICulture" />
<MemberSignature Language="DocId" Value="P:System.Globalization.CultureInfo.DefaultThreadCurrentUICulture" />
<MemberSignature Language="VB.NET" Value="Public Shared Property DefaultThreadCurrentUICulture As CultureInfo" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; static property System::Globalization::CultureInfo ^ DefaultThreadCurrentUICulture { System::Globalization::CultureInfo ^ get(); void set(System::Globalization::CultureInfo ^ value); };" />
<MemberSignature Language="F#" Value="member this.DefaultThreadCurrentUICulture : System.Globalization.CultureInfo with get, set" Usage="System.Globalization.CultureInfo.DefaultThreadCurrentUICulture" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Globalization</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime</AssemblyName>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netstandard-1.0;netstandard-1.1;netstandard-1.2;netframework-4.8">
<AttributeName>set: System.Security.SecuritySafeCritical</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Globalization.CultureInfo</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets the default UI culture for threads in the current application domain.</summary>
<value>The default UI culture for threads in the current application domain, or <see langword="null" /> if the current system UI culture is the default thread UI culture in the application domain.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
In the [!INCLUDE[net_v40_long](~/includes/net-v40-long-md.md)] and previous versions, by default, the UI culture of all threads is set to the Windows system culture. For applications whose current UI culture differs from the default system culture, this behavior is often undesirable. In the [!INCLUDE[net_v45](~/includes/net-v45-md.md)], the <xref:System.Globalization.CultureInfo.DefaultThreadCurrentUICulture%2A> property lets you define the default UI culture of all threads in an application domain.
> [!IMPORTANT]
> If you have not explicitly set the UI culture of any existing threads executing in an application domain, setting the <xref:System.Globalization.CultureInfo.DefaultThreadCurrentUICulture%2A> property also changes the culture of these threads. However, if these threads execute in another application domain, their culture is defined by the <xref:System.Globalization.CultureInfo.DefaultThreadCurrentUICulture%2A> property in that application domain or, if no default value is defined, by the default system culture. Because of this, we recommend that you always explicitly set the culture of your main application thread and do not rely on the <xref:System.Globalization.CultureInfo.DefaultThreadCurrentUICulture%2A> property to define the culture of the main application thread.
Unless it is set explicitly, the value of the <xref:System.Globalization.CultureInfo.DefaultThreadCurrentUICulture%2A> property is `null`, and the current culture of all threads in an application domain that have not been assigned an explicit culture is defined by the default Windows system culture.
For more information about cultures, threads, and application domains, see the "Culture and threads" and "Culture and application domains" sections in the <xref:System.Globalization.CultureInfo> reference page.
## Examples
The following example illustrates the default behavior of the .NET Framework in defining the current culture of a new thread. It uses English and Russian language resources. The following text file named GreetingStrings.txt contains the English language resources:
```
greeting =Hello again!
newGreeting=Hello!
```
It is compiled to a binary .resources file named GreetingStrings.resources by using the [Resource File Generator](~/docs/framework/tools/resgen-exe-resource-file-generator.md) with the following command.
```console
resgen greetingstrings.txt
```
The following text file named GreetingStrings.ru-RU.txt contains the Russian language resources:
```
greeting=Еще раз привет!
newGreeting=Привет!
```
It is compiled to a binary .resources file named GreetingStrings.ru-RU.resources by using the [Resource File Generator](~/docs/framework/tools/resgen-exe-resource-file-generator.md) with the following command.
```console
resgen greetingstrings.ru-RU.txt
```
The application code, which is shown below, resides in a file named Example1.vb or Example1.cs. It is compiled to an executable by using the following command for the Visual Basic compiler:
```console
vbc Example1.vb /resource:GreetingStrings.resources
```
For the C# compiler, the command is similar:
```console
csc /resource:GreetingStrings.resources Example1.cs
```
This creates an assembly that includes the example's executable code along with the resources for its fallback culture. You can also use the [Assembly Linker](~/docs/framework/tools/al-exe-assembly-linker.md) to create the resource file for the Russian (Russia) culture with the following command:
```console
>al /embed:greetingstrings.ru-RU.resources /c:ru-RU /template:example1.exe /out:ru-RU\Example1.resources.dll
```
At startup, the example sets the current culture and the current UI culture to Russian (Russia) on all systems except those on which the default system culture is already Russian (Russia). If the default system culture is already Russian (Russia), the code sets the current culture and the current UI culture to English (United States). It then calls the `ShowGreeting` routine, which displays a simple string the first time it is called and a slightly different string on subsequent method calls. Next, it creates a new thread, which also executes the `ShowGreeting` routine.
[!code-csharp[System.Globalization.CultureInfo.DefaultThreadCurrentUICulture#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.globalization.cultureinfo.defaultthreadcurrentuiculture/cs/example1.cs#1)]
[!code-vb[System.Globalization.CultureInfo.DefaultThreadCurrentUICulture#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.cultureinfo.defaultthreadcurrentuiculture/vb/example1.vb#1)]
As the output from the example shows, when the example is run on a computer whose system culture is English (United States), the main thread displays its initial string in Russian. However, because the worker thread's culture is derived from the current Windows system culture rather than the application's current culture, the worker thread displays its string in English.
The following example uses the <xref:System.Globalization.CultureInfo.DefaultThreadCurrentCulture%2A> and <xref:System.Globalization.CultureInfo.DefaultThreadCurrentUICulture%2A> properties to define the current culture and current UI culture of a new application thread.
The example uses the same resources files as the previous example. The commands to compile and to embed the localized Russian language resources into a satellite assembly are also identical, except that the name of the executable assembly changes.
At startup, the example sets the current culture and the current UI culture to Russian (Russia) on all systems except those on which the default system culture is already Russian (Russia). If the default system culture is already Russian (Russia), it sets the current culture and the current UI culture to English (United States). It then calls the `ShowGreeting` routine, which displays a simple string the first time it is called and a slightly different string on subsequent method calls. Next, it creates a new thread, which also executes the `ShowGreeting` routine.
[!code-csharp[System.Globalization.CultureInfo.DefaultThreadCurrentUICulture#2](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.globalization.cultureinfo.defaultthreadcurrentuiculture/cs/example2.cs#2)]
[!code-vb[System.Globalization.CultureInfo.DefaultThreadCurrentUICulture#2](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.cultureinfo.defaultthreadcurrentuiculture/vb/example2.vb#2)]
As the output from the example shows, when the example is run on a computer whose system culture is English (United States), both the main thread and the worker thread display their strings in the Russian language.
]]></format>
</remarks>
<exception cref="T:System.ArgumentException">In a set operation, the <see cref="P:System.Globalization.CultureInfo.Name" /> property value is invalid.</exception>
<altmember cref="P:System.Globalization.CultureInfo.CurrentUICulture" />
<altmember cref="P:System.Globalization.CultureInfo.DefaultThreadCurrentCulture" />
</Docs>
</Member>
<Member MemberName="DisplayName">
<MemberSignature Language="C#" Value="public virtual string DisplayName { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance string DisplayName" />
<MemberSignature Language="DocId" Value="P:System.Globalization.CultureInfo.DisplayName" />
<MemberSignature Language="VB.NET" Value="Public Overridable ReadOnly Property DisplayName As String" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; virtual property System::String ^ DisplayName { System::String ^ get(); };" />
<MemberSignature Language="F#" Value="member this.DisplayName : string" Usage="System.Globalization.CultureInfo.DisplayName" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Globalization</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime</AssemblyName>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netstandard-1.0;netstandard-1.1;netstandard-1.2;netframework-4.8">
<AttributeName>get: System.Security.SecuritySafeCritical</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets the full localized culture name.</summary>
<value>The full localized culture name in the format *languagefull* [*country/regionfull*], where *languagefull* is the full name of the language and *country/regionfull* is the full name of the country/region.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
This property represents the localized name of the <xref:System.Globalization.CultureInfo> object.
Culture names may vary due to scripting or formatting conventions. You should use the returned name for display, and not attempt to parse it.
If a custom culture is created by means of the <xref:System.Globalization.CultureAndRegionInfoBuilder> class, the <xref:System.Globalization.CultureInfo.DisplayName%2A> property is initialized to the value of the <xref:System.Globalization.CultureInfo.NativeName%2A> property.
## Examples
The following code example displays several properties of the neutral cultures.
> [!NOTE]
> The example displays the zh-CHS and zh-CHT cultures with the 0x0004 and 0x7C04 culture identifiers, respectively. However, your Windows Vista applications should use the zh-Hans name instead of zh-CHS and the zh-Hant name instead of zh-CHT. The zh-Hans and zh-Hant names represent the current standard, and should be used unless you have a reason for using the older names.
[!code-cpp[System.Globalization.CultureInfo.GetCultures#1](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.GetCultures/CPP/getcultures.cpp#1)]
[!code-csharp[System.Globalization.CultureInfo.GetCultures#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.GetCultures/CS/getcultures.cs#1)]
[!code-vb[System.Globalization.CultureInfo.GetCultures#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CultureInfo.GetCultures/VB/getcultures.vb#1)]
]]></format>
</remarks>
<altmember cref="P:System.Globalization.CultureInfo.Name" />
<altmember cref="P:System.Globalization.CultureInfo.NativeName" />
<altmember cref="P:System.Globalization.CultureInfo.EnglishName" />
<altmember cref="P:System.Globalization.CultureInfo.TwoLetterISOLanguageName" />
<altmember cref="P:System.Globalization.CultureInfo.ThreeLetterISOLanguageName" />
<altmember cref="P:System.Globalization.CultureInfo.ThreeLetterWindowsLanguageName" />
</Docs>
</Member>
<Member MemberName="EnglishName">
<MemberSignature Language="C#" Value="public virtual string EnglishName { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance string EnglishName" />
<MemberSignature Language="DocId" Value="P:System.Globalization.CultureInfo.EnglishName" />
<MemberSignature Language="VB.NET" Value="Public Overridable ReadOnly Property EnglishName As String" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; virtual property System::String ^ EnglishName { System::String ^ get(); };" />
<MemberSignature Language="F#" Value="member this.EnglishName : string" Usage="System.Globalization.CultureInfo.EnglishName" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Globalization</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime</AssemblyName>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netstandard-1.0;netstandard-1.1;netstandard-1.2;netframework-4.8">
<AttributeName>get: System.Security.SecuritySafeCritical</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets the culture name in the format *languagefull* [*country/regionfull*] in English.</summary>
<value>The culture name in the format *languagefull* [*country/regionfull*] in English, where *languagefull* is the full name of the language and *country/regionfull* is the full name of the country/region.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
For example, the <xref:System.Globalization.CultureInfo.EnglishName%2A> for the specific culture name en-US is "English (United States)".
The value of this property is the same, regardless of the language version of the .NET Framework.
## Examples
The following code example displays several properties of the neutral cultures.
> [!NOTE]
> The example displays the older zh-CHS and zh-CHT culture names with the 0x0004 and 0x7C04 culture identifiers, respectively. However, your Windows Vista applications should use the zh-Hans name instead of zh-CHS and the zh-Hant name instead of zh-CHT. The zh-Hans and zh-Hant names represent the current standard, and should be used unless you have a reason for using the older names.
[!code-cpp[System.Globalization.CultureInfo.GetCultures#1](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.GetCultures/CPP/getcultures.cpp#1)]
[!code-csharp[System.Globalization.CultureInfo.GetCultures#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.GetCultures/CS/getcultures.cs#1)]
[!code-vb[System.Globalization.CultureInfo.GetCultures#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CultureInfo.GetCultures/VB/getcultures.vb#1)]
]]></format>
</remarks>
<altmember cref="P:System.Globalization.CultureInfo.Name" />
<altmember cref="P:System.Globalization.CultureInfo.DisplayName" />
<altmember cref="P:System.Globalization.CultureInfo.NativeName" />
<altmember cref="P:System.Globalization.CultureInfo.TwoLetterISOLanguageName" />
<altmember cref="P:System.Globalization.CultureInfo.ThreeLetterISOLanguageName" />
<altmember cref="P:System.Globalization.CultureInfo.ThreeLetterWindowsLanguageName" />
</Docs>
</Member>
<Member MemberName="Equals">
<MemberSignature Language="C#" Value="public override bool Equals (object value);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig virtual instance bool Equals(object value) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Globalization.CultureInfo.Equals(System.Object)" />
<MemberSignature Language="VB.NET" Value="Public Overrides Function Equals (value As Object) As Boolean" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; override bool Equals(System::Object ^ value);" />
<MemberSignature Language="F#" Value="override this.Equals : obj -&gt; bool" Usage="cultureInfo.Equals value" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Globalization</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime</AssemblyName>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="value" Type="System.Object" />
</Parameters>
<Docs>
<param name="value">The object to compare with the current <see cref="T:System.Globalization.CultureInfo" />.</param>
<summary>Determines whether the specified object is the same culture as the current <see cref="T:System.Globalization.CultureInfo" />.</summary>
<returns>
<see langword="true" /> if <paramref name="value" /> is the same culture as the current <see cref="T:System.Globalization.CultureInfo" />; otherwise, <see langword="false" />.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
This method overrides <xref:System.Object.Equals%2A?displayProperty=nameWithType>.
Two <xref:System.Globalization.CultureInfo> objects are considered equal if their <xref:System.Globalization.CultureInfo.Name%2A> and <xref:System.Globalization.CultureInfo.CompareInfo%2A> properties are equal.
]]></format>
</remarks>
<altmember cref="M:System.Object.Equals(System.Object)" />
</Docs>
</Member>
<Member MemberName="GetConsoleFallbackUICulture">
<MemberSignature Language="C#" Value="public System.Globalization.CultureInfo GetConsoleFallbackUICulture ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance class System.Globalization.CultureInfo GetConsoleFallbackUICulture() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Globalization.CultureInfo.GetConsoleFallbackUICulture" />
<MemberSignature Language="VB.NET" Value="Public Function GetConsoleFallbackUICulture () As CultureInfo" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; System::Globalization::CultureInfo ^ GetConsoleFallbackUICulture();" />
<MemberSignature Language="F#" Value="member this.GetConsoleFallbackUICulture : unit -&gt; System.Globalization.CultureInfo" Usage="cultureInfo.GetConsoleFallbackUICulture " />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime</AssemblyName>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Globalization</AssemblyName>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netframework-4.8">
<AttributeName>System.Runtime.InteropServices.ComVisible(false)</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8">
<AttributeName>System.Security.SecuritySafeCritical</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Globalization.CultureInfo</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<summary>Gets an alternate user interface culture suitable for console applications when the default graphic user interface culture is unsuitable.</summary>
<returns>An alternate culture that is used to read and display text on the console.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Languages such as Arabic, Hebrew, Urdu, and Syriac are based on bidirectional text. Windows applications, which have a graphical user interface, support bidirectional languages. However, console applications, which employ the text user interface of the operating system console, do not provide bidirectional support. Therefore, if you localize a console application to Arabic or Hebrew, your application displays unreadable text on the console screen.
The user interface culture specifies the resources an application needs to support user input and output, and by default is the same as the operating system culture. For example, the <xref:System.Globalization.CultureInfo.CurrentUICulture%2A?displayProperty=nameWithType> property returns an Arabic culture for an Arabic operating system. Use the <xref:System.Globalization.CultureInfo.GetConsoleFallbackUICulture%2A> method to retrieve a culture suitable for a console application user interface. After your application retrieves the fallback user interface culture, it should assign the culture to the current user interface culture of the current thread. For more information, see the "Explicitly Setting the Current UI Culture" section of the <xref:System.Globalization.CultureInfo.CurrentUICulture%2A> property.
The following are predefined cultures that have a different fallback user interface culture name from the predefined culture name.
|Predefined culture|Culture name|Fallback user interface culture name|
|------------------------|------------------|------------------------------------------|
|Amharic|am|en-US|
|Amharic (Ethiopia)|am-ET|en-US|
|(neutral Arabic)|ar|en-US|
|Arabic (U.A.E.)|ar-AE|en-US|
|Arabic (Bahrain)|ar-BH|en-US|
|Arabic (Algeria)|ar-DZ|fr-FR|
|Arabic (Egypt)|ar-EG|en-US|
|Arabic (Iraq)|ar-IQ|en-US|
|Arabic (Jordan)|ar-JO|en-US|
|Arabic (Kuwait)|ar-KW|en-US|
|Arabic (Lebanon)|ar-LB|en-US|
|Arabic (Libya)|ar-LY|en-US|
|Arabic (Morocco)|ar-MA|fr-FR|
|Arabic (Oman)|ar-OM|en-US|
|Arabic (Qatar)|ar-QA|en-US|
|Arabic (Saudi Arabia)|ar-SA|en-US|
|Arabic (Syria)|ar-SY|en-US|
|Arabic (Tunisia)|ar-TN|fr-FR|
|Arabic (Yemen)|ar-YE|en-US|
|Assamese|as|en-US|
|Assamese (India)|as-IN|en-US|
|Bangla|bn|en-US|
|Bangla (Bangladesh)|bn-BD|en-US|
|Bangla (India)|bn-IN|en-US|
|Tibetan|bo|en-US|
|Tibetan (PRC)|bo-CN|en-US|
|Divehi|dv|en-US|
|Divehi (India)|dv-MV|en-US|
|Persian|fa|en-US|
|Persian (Iran)|fa-IR|en-US|
|Gujarati|gu|en-US|
|Gujarati (India)|gu-IN|en-US|
|Hebrew|he|en-US|
|Hebrew (Israel)|he-IL|en-US|
|Hindi|hi|en-US|
|Hindi (India)|hi-IN|en-US|
|Yi|ii|en-US|
|Yi (PRC)|ii-CN|en-US|
|Inukitut Syllabics|iu-Cans|en-US|
|Inukitut Syllabics (Canada)|iu-Cans-CA|en-US|
|Khmer|km|en-US|
|Khmer (Cambodia)|km-KH|en-US|
|Kannada|kn|en-US|
|Kannada (India)|kn-IN|en-US|
|Konkani|kok|en-US|
|Konkani (India)|kok-IN|en-US|
|Lao|lo|en-US|
|Lao (Lao P.D.R.)|lo-LA|en-US|
|Malayalam|ml|en-US|
|Malayalam (India)|ml-IN|en-US|
|Mohawk|moh|en-US|
|Mohawk (Canada)|moh-CA|en-US|
|Marathi|mr|en-US|
|Marathi (India)|mr-IN|en-US|
|Nepali|ne|en-US|
|Nepali (Nepal)|ne-NP|en-US|
|Norwegian|no|nb-NO|
|Odiya|or|en-US|
|Odiya (India)|or-IN|en-US|
|Punjabi|pa|en-US|
|Punjabi (India)|pa-IN|en-US|
|Dari|prs|en-US|
|Dari (Afghanistan)|prs-AF|en-US|
|Pashto|ps|en-US|
|Pashto (Afghanistan)|ps-AF|en-US|
|Sanskrit|sa|en-US|
|Sanskrit (India)|sa-IN|en-US|
|Sinhala|si|en-US|
|Sinhala (Sri Lanka)|si-LK|en-US|
|Syriac|syr|en-US|
|Syriac (Syria)|syr-SY|en-US|
|Tamil|ta|en-US|
|Tamil (India)|ta-IN|en-US|
|Telugu|te|en-US|
|Telugu (India)|te-IN|en-US|
|Thai|th|en-US|
|Thai (Thailand)|th-Th|en-US|
|Uighur|ug|en-US|
|Uighur (PRC)|ug-CN|en-US|
|Urdu|ur|en-US|
|Urdu (Pakistan)|ur-PK|en-US|
|Vietnamese|vi|en-US|
|Vietnamese (Vietnam)|vi-VN|en-US|
Your application can use <xref:System.Globalization.CultureAndRegionInfoBuilder> to create a replacement for a culture, and that culture can have a console fallback culture of your choosing.
## Examples
The following code example displays the fallback user interface culture associated with a culture object.
[!code-cpp[sys.glob.ci.getCFUIC#1](~/samples/snippets/cpp/VS_Snippets_CLR/sys.glob.ci.getCFUIC/cpp/cfuic.cpp#1)]
[!code-csharp[sys.glob.ci.getCFUIC#1](~/samples/snippets/csharp/VS_Snippets_CLR/sys.glob.ci.getCFUIC/CS/cfuic.cs#1)]
[!code-vb[sys.glob.ci.getCFUIC#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/sys.glob.ci.getCFUIC/VB/cfuic.vb#1)]
]]></format>
</remarks>
</Docs>
</Member>
<MemberGroup MemberName="GetCultureInfo">
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Docs>
<summary>Retrieves a cached, read-only instance of a culture.</summary>
</Docs>
</MemberGroup>
<Member MemberName="GetCultureInfo">
<MemberSignature Language="C#" Value="public static System.Globalization.CultureInfo GetCultureInfo (int culture);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig class System.Globalization.CultureInfo GetCultureInfo(int32 culture) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Globalization.CultureInfo.GetCultureInfo(System.Int32)" />
<MemberSignature Language="VB.NET" Value="Public Shared Function GetCultureInfo (culture As Integer) As CultureInfo" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; static System::Globalization::CultureInfo ^ GetCultureInfo(int culture);" />
<MemberSignature Language="F#" Value="static member GetCultureInfo : int -&gt; System.Globalization.CultureInfo" Usage="System.Globalization.CultureInfo.GetCultureInfo culture" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime</AssemblyName>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Globalization</AssemblyName>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Globalization.CultureInfo</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="culture" Type="System.Int32" Index="0" FrameworkAlternate="netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netstandard-2.0;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netstandard-2.1" />
</Parameters>
<Docs>
<param name="culture">A locale identifier (LCID).</param>
<summary>Retrieves a cached, read-only instance of a culture by using the specified culture identifier.</summary>
<returns>A read-only <see cref="T:System.Globalization.CultureInfo" /> object.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
We recommend that you use the string overload of this method (<xref:System.Globalization.CultureInfo.GetCultureInfo%28System.String%29>), because locale names should be used instead of LCIDs. For custom locales, the locale name is required.
If `culture` is the locale identifier of the current culture, the returned <xref:System.Globalization.CultureInfo> object does not reflect any user overrides.
]]></format>
</remarks>
<exception cref="T:System.ArgumentOutOfRangeException">
<paramref name="culture" /> is less than zero.</exception>
<exception cref="T:System.Globalization.CultureNotFoundException">
<paramref name="culture" /> specifies a culture that is not supported. See the Notes to Caller section for more information.</exception>
<block subset="none" type="usage">
<para>The [!INCLUDE[net_v35_long](~/includes/net-v35-long-md.md)] and earlier versions throw an <see cref="T:System.ArgumentException" /> if <paramref name="culture" /> is not a valid culture identifier. Starting with the [!INCLUDE[net_v40_long](~/includes/net-v40-long-md.md)], this method throws a <see cref="T:System.Globalization.CultureNotFoundException" />. Starting with apps that run under the [!INCLUDE[net_v40_long](~/includes/net-v40-long-md.md)] or later on Windows 7 or later, the method attempts to retrieve a <see cref="T:System.Globalization.CultureInfo" /> object whose identifier is <paramref name="culture" /> from the operating system; if the operating system does not support that culture, the method throws a <see cref="T:System.Globalization.CultureNotFoundException" />.</para>
</block>
<altmember cref="P:System.Globalization.CultureInfo.LCID" />
<altmember cref="M:System.Globalization.CultureInfo.ClearCachedData" />
</Docs>
</Member>
<Member MemberName="GetCultureInfo">
<MemberSignature Language="C#" Value="public static System.Globalization.CultureInfo GetCultureInfo (string name);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig class System.Globalization.CultureInfo GetCultureInfo(string name) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Globalization.CultureInfo.GetCultureInfo(System.String)" />
<MemberSignature Language="VB.NET" Value="Public Shared Function GetCultureInfo (name As String) As CultureInfo" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; static System::Globalization::CultureInfo ^ GetCultureInfo(System::String ^ name);" />
<MemberSignature Language="F#" Value="static member GetCultureInfo : string -&gt; System.Globalization.CultureInfo" Usage="System.Globalization.CultureInfo.GetCultureInfo name" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime</AssemblyName>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Globalization</AssemblyName>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Globalization.CultureInfo</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="name" Type="System.String" Index="0" FrameworkAlternate="netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netstandard-2.0;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netstandard-2.1" />
</Parameters>
<Docs>
<param name="name">The name of a culture. <paramref name="name" /> is not case-sensitive.</param>
<summary>Retrieves a cached, read-only instance of a culture using the specified culture name.</summary>
<returns>A read-only <see cref="T:System.Globalization.CultureInfo" /> object.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
For a list of predefined culture names on Windows systems, see the **Language tag** column in the [list of language/region names supported by Windows](https://docs.microsoft.com/openspecs/windows_protocols/ms-lcid/a9eac961-e77d-41a6-90a5-ce1a8b0cdb9c). Culture names follow the standard defined by [BCP 47](https://tools.ietf.org/html/bcp47). In addition, starting with Windows 10, `name` can be any valid BCP-47 language tag.
The <xref:System.Globalization.CultureInfo.GetCultureInfo%2A> method retrieves a cached, read-only <xref:System.Globalization.CultureInfo> object. It offers better performance than a corresponding call to the <xref:System.Globalization.CultureInfo.%23ctor%28System.String%29?displayProperty=nameWithType> constructor.
If `name` is the name of the current culture, the returned <xref:System.Globalization.CultureInfo> object does not reflect any user overrides. This makes the method suitable for server applications or tools that do not have a real user account on the system and that need to load multiple cultures efficiently.
If `name` is <xref:System.String.Empty?displayProperty=nameWithType>, the method returns the invariant culture. This is equivalent to retrieving the value of the <xref:System.Globalization.CultureInfo.InvariantCulture%2A> property.
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="name" /> is null.</exception>
<exception cref="T:System.Globalization.CultureNotFoundException">
<paramref name="name" /> specifies a culture that is not supported. See the Notes to Callers section for more information.</exception>
<block subset="none" type="usage">
<para>The [!INCLUDE[net_v35_long](~/includes/net-v35-long-md.md)] and earlier versions throw an <see cref="T:System.ArgumentException" /> if <paramref name="name" /> is not a valid culture name. Starting with the [!INCLUDE[net_v40_long](~/includes/net-v40-long-md.md)], this method throws a <see cref="T:System.Globalization.CultureNotFoundException" />. Starting with apps that run under the [!INCLUDE[net_v40_long](~/includes/net-v40-long-md.md)] or later on Windows 7 or later, the method attempts to retrieve a <see cref="T:System.Globalization.CultureInfo" /> object whose identifier is <paramref name="name" /> from the operating system; if the operating system does not support that culture, and if <paramref name="name" /> is not the name of a supplementary or replacement culture, the method throws a <see cref="T:System.Globalization.CultureNotFoundException" />.</para>
</block>
<altmember cref="P:System.Globalization.CultureInfo.Name" />
</Docs>
</Member>
<Member MemberName="GetCultureInfo">
<MemberSignature Language="C#" Value="public static System.Globalization.CultureInfo GetCultureInfo (string name, string altName);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig class System.Globalization.CultureInfo GetCultureInfo(string name, string altName) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Globalization.CultureInfo.GetCultureInfo(System.String,System.String)" />
<MemberSignature Language="VB.NET" Value="Public Shared Function GetCultureInfo (name As String, altName As String) As CultureInfo" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; static System::Globalization::CultureInfo ^ GetCultureInfo(System::String ^ name, System::String ^ altName);" />
<MemberSignature Language="F#" Value="static member GetCultureInfo : string * string -&gt; System.Globalization.CultureInfo" Usage="System.Globalization.CultureInfo.GetCultureInfo (name, altName)" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime</AssemblyName>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Globalization</AssemblyName>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Globalization.CultureInfo</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="name" Type="System.String" Index="0" FrameworkAlternate="netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netstandard-2.0;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netstandard-2.1" />
<Parameter Name="altName" Type="System.String" Index="1" FrameworkAlternate="netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netstandard-2.0;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netstandard-2.1" />
</Parameters>
<Docs>
<param name="name">The name of a culture. <paramref name="name" /> is not case-sensitive.</param>
<param name="altName">The name of a culture that supplies the <see cref="T:System.Globalization.TextInfo" /> and <see cref="T:System.Globalization.CompareInfo" /> objects used to initialize <paramref name="name" />. <paramref name="altName" /> is not case-sensitive.</param>
<summary>Retrieves a cached, read-only instance of a culture. Parameters specify a culture that is initialized with the <see cref="T:System.Globalization.TextInfo" /> and <see cref="T:System.Globalization.CompareInfo" /> objects specified by another culture.</summary>
<returns>A read-only <see cref="T:System.Globalization.CultureInfo" /> object.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
For a list of predefined culture names on Windows systems, see the **Language tag** column in the [list of language/region names supported by Windows](https://docs.microsoft.com/openspecs/windows_protocols/ms-lcid/a9eac961-e77d-41a6-90a5-ce1a8b0cdb9c). Culture names follow the standard defined by [BCP 47](https://tools.ietf.org/html/bcp47). In addition, starting with Windows 10, `name` can be any valid BCP-47 language tag.
The <xref:System.Globalization.CultureInfo.GetCultureInfo%2A> method obtains a cached, read-only <xref:System.Globalization.CultureInfo> object. It offers better performance than a corresponding call to a <xref:System.Globalization.CultureInfo.%23ctor%2A> constructor. The method is used to create a culture similar to that specified by the `name` parameter, but with different sorting and casing rules.
If `name` or `altName` is the name of the current culture, the returned objects do not reflect any user overrides. If `name` is <xref:System.String.Empty?displayProperty=nameWithType>, the method returns the invariant culture. This is equivalent to retrieving the value of the <xref:System.Globalization.CultureInfo.InvariantCulture%2A> property. If `altName` is <xref:System.String.Empty?displayProperty=nameWithType>, the method uses the writing system and comparison rules specified by the invariant culture.
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="name" /> or <paramref name="altName" /> is null.</exception>
<exception cref="T:System.Globalization.CultureNotFoundException">
<paramref name="name" /> or <paramref name="altName" /> specifies a culture that is not supported. See the Notes to Callers section for more information.</exception>
<block subset="none" type="usage">
<para>The [!INCLUDE[net_v35_long](~/includes/net-v35-long-md.md)] and earlier versions throw an <see cref="T:System.ArgumentException" /> if <paramref name="name" /> or <paramref name="altName" /> is not a valid culture name. Starting with the [!INCLUDE[net_v40_long](~/includes/net-v40-long-md.md)], this method throws a <see cref="T:System.Globalization.CultureNotFoundException" />. Starting with apps that run under the [!INCLUDE[net_v40_long](~/includes/net-v40-long-md.md)] or later on Windows 7 or later, the method attempts to retrieve a <see cref="T:System.Globalization.CultureInfo" /> object whose identifier is <paramref name="name" /> from the operating system; if the operating system does not support that culture, and if <paramref name="name" /> is not the name of a supplementary or replacement culture, the method throws a <see cref="T:System.Globalization.CultureNotFoundException" /> exception. Starting with apps that run under the [!INCLUDE[net_v40_long](~/includes/net-v40-long-md.md)] or later on Windows 7 or later, the method attempts to retrieve a <see cref="T:System.Globalization.CultureInfo" /> object whose identifier is <paramref name="name" /> from the operating system; if the operating system does not support that culture, and if <paramref name="name" /> is not the name of a supplementary or replacement culture, the method throws a <see cref="T:System.Globalization.CultureNotFoundException" /> exception.</para>
</block>
<altmember cref="P:System.Globalization.CultureInfo.Name" />
<altmember cref="M:System.Globalization.CultureInfo.ClearCachedData" />
</Docs>
</Member>
<Member MemberName="GetCultureInfoByIetfLanguageTag">
<MemberSignature Language="C#" Value="public static System.Globalization.CultureInfo GetCultureInfoByIetfLanguageTag (string name);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig class System.Globalization.CultureInfo GetCultureInfoByIetfLanguageTag(string name) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Globalization.CultureInfo.GetCultureInfoByIetfLanguageTag(System.String)" />
<MemberSignature Language="VB.NET" Value="Public Shared Function GetCultureInfoByIetfLanguageTag (name As String) As CultureInfo" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; static System::Globalization::CultureInfo ^ GetCultureInfoByIetfLanguageTag(System::String ^ name);" />
<MemberSignature Language="F#" Value="static member GetCultureInfoByIetfLanguageTag : string -&gt; System.Globalization.CultureInfo" Usage="System.Globalization.CultureInfo.GetCultureInfoByIetfLanguageTag name" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime</AssemblyName>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Globalization</AssemblyName>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Globalization.CultureInfo</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="name" Type="System.String" Index="0" FrameworkAlternate="netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netstandard-2.0;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netstandard-2.1" />
</Parameters>
<Docs>
<param name="name">The name of a language as specified by the RFC 4646 standard.</param>
<summary>Deprecated. Retrieves a read-only <see cref="T:System.Globalization.CultureInfo" /> object having linguistic characteristics that are identified by the specified RFC 4646 language tag.</summary>
<returns>A read-only <see cref="T:System.Globalization.CultureInfo" /> object.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
> [!NOTE]
> This method and the <xref:System.Globalization.CultureInfo.IetfLanguageTag%2A> property are deprecated. Instead of using these elements, the application should use a new <xref:System.Globalization.CultureInfo> object and calls to the <xref:System.Globalization.CultureInfo.Name%2A> property. IETF tags and names are identical.
The RFC 4646 standard that is maintained by the Internet Engineering Task Force (IETF) defines an IETF language tag, which provides a uniform means of identifying a language. The format of an IETF language tag is the same as the culture name returned by the <xref:System.Globalization.CultureInfo.Name%2A> property, but does not identify a culture uniquely. Different cultures share the same IETF language tag if those cultures have identical linguistic characteristics. The linguistic characteristics of a culture are contained in the <xref:System.Globalization.TextInfo> object associated with a <xref:System.Globalization.CultureInfo> object.
An IETF language tag consists of a mandatory language identifier, an optional script identifier, and an optional region identifier.
Your applications should use the retrieved culture to control language-specific tasks, such as managing a spelling or grammar checker. Applications should not use the retrieved culture to control culture-specific tasks, such as sorting text or formatting times and dates.
For more information, see RFC 4646, "Tags for Identifying Languages," and the most recent draft standard, Draft-phillips-langtags-05.txt, at [http://go.microsoft.com/fwlink/?LinkId=100231](https://go.microsoft.com/fwlink/?LinkId=100231).
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="name" /> is null.</exception>
<exception cref="T:System.Globalization.CultureNotFoundException">
<paramref name="name" /> does not correspond to a supported culture.</exception>
<block subset="none" type="usage">
<para>The [!INCLUDE[net_v35_long](~/includes/net-v35-long-md.md)] and earlier versions throw an <see cref="T:System.ArgumentException" /> if <paramref name="name" /> does not correspond to the name of a supported culture. Starting with the [!INCLUDE[net_v40_long](~/includes/net-v40-long-md.md)], this method throws a <see cref="T:System.Globalization.CultureNotFoundException" />.</para>
</block>
<altmember cref="P:System.Globalization.CultureInfo.TextInfo" />
<altmember cref="T:System.Globalization.CultureAndRegionInfoBuilder" />
<altmember cref="M:System.Globalization.CultureInfo.ClearCachedData" />
</Docs>
</Member>
<Member MemberName="GetCultures">
<MemberSignature Language="C#" Value="public static System.Globalization.CultureInfo[] GetCultures (System.Globalization.CultureTypes types);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig class System.Globalization.CultureInfo[] GetCultures(valuetype System.Globalization.CultureTypes types) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Globalization.CultureInfo.GetCultures(System.Globalization.CultureTypes)" />
<MemberSignature Language="VB.NET" Value="Public Shared Function GetCultures (types As CultureTypes) As CultureInfo()" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; static cli::array &lt;System::Globalization::CultureInfo ^&gt; ^ GetCultures(System::Globalization::CultureTypes types);" />
<MemberSignature Language="F#" Value="static member GetCultures : System.Globalization.CultureTypes -&gt; System.Globalization.CultureInfo[]" Usage="System.Globalization.CultureInfo.GetCultures types" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime</AssemblyName>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Globalization</AssemblyName>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Globalization.CultureInfo[]</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="types" Type="System.Globalization.CultureTypes" Index="0" FrameworkAlternate="netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netframework-1.1;netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netstandard-2.0;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netstandard-2.1" />
</Parameters>
<Docs>
<param name="types">A bitwise combination of the enumeration values that filter the cultures to retrieve.</param>
<summary>Gets the list of supported cultures filtered by the specified <see cref="T:System.Globalization.CultureTypes" /> parameter.</summary>
<returns>An array that contains the cultures specified by the <paramref name="types" /> parameter. The array of cultures is unsorted.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Globalization.CultureInfo.GetCultures%2A> method is most commonly called with the `types` parameter set to the following values:
- <xref:System.Globalization.CultureTypes.SpecificCultures>, which returns all specific cultures.
- <xref:System.Globalization.CultureTypes.NeutralCultures>, which returns all neutral cultures and the invariant culture.
- <xref:System.Globalization.CultureTypes.AllCultures>, which returns all neutral and specific cultures, cultures installed in the Windows system, and custom cultures created by the user.
- <xref:System.Globalization.CultureTypes.UserCustomCulture>, which returns all custom cultures, such as those registered by the <xref:System.Globalization.CultureAndRegionInfoBuilder> class. In versions of Windows before Windows 10, the <xref:System.Globalization.CultureTypes.UserCustomCulture> value applies to all user-defined custom cultures. Starting with Windows 10, it applies to system cultures that lack complete cultural data and that do not have a unique local identifier, as indicated by the <xref:System.Globalization.CultureInfo.LCID%2A> property value. As a result, code such as the following will return different results when run on Windows 10 and on an earlier version of Windows.
[!code-csharp[System.Globalization.CultureInfo.GetCultures#2](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.GetCultures/CS/getcultures3.cs#2)]
[!code-vb[System.Globalization.CultureInfo.GetCultures#2](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CultureInfo.GetCultures/VB/getcultures3.vb#2)]
## Examples
The following code example displays several properties of the neutral cultures.
> [!NOTE]
> The example displays the zh-CHS and zh-CHT cultures with the 0x0004 and 0x7C04 culture identifiers, respectively. However, your Windows Vista applications should use the zh-Hans name instead of zh-CHS and the zh-Hant name instead of zh-CHT. The zh-Hans and zh-Hant names represent the current standard, and should be used unless you have a reason for using the older names.
[!code-cpp[System.Globalization.CultureInfo.GetCultures#1](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.GetCultures/CPP/getcultures.cpp#1)]
[!code-csharp[System.Globalization.CultureInfo.GetCultures#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.GetCultures/CS/getcultures.cs#1)]
[!code-vb[System.Globalization.CultureInfo.GetCultures#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CultureInfo.GetCultures/VB/getcultures.vb#1)]
]]></format>
</remarks>
<exception cref="T:System.ArgumentOutOfRangeException">
<paramref name="types" /> specifies an invalid combination of <see cref="T:System.Globalization.CultureTypes" /> values.</exception>
<altmember cref="T:System.Globalization.CultureTypes" />
</Docs>
</Member>
<Member MemberName="GetFormat">
<MemberSignature Language="C#" Value="public virtual object GetFormat (Type formatType);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance object GetFormat(class System.Type formatType) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Globalization.CultureInfo.GetFormat(System.Type)" />
<MemberSignature Language="VB.NET" Value="Public Overridable Function GetFormat (formatType As Type) As Object" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; virtual System::Object ^ GetFormat(Type ^ formatType);" />
<MemberSignature Language="F#" Value="abstract member GetFormat : Type -&gt; obj&#xA;override this.GetFormat : Type -&gt; obj" Usage="cultureInfo.GetFormat formatType" />
<MemberType>Method</MemberType>
<Implements>
<InterfaceMember>M:System.IFormatProvider.GetFormat(System.Type)</InterfaceMember>
</Implements>
<AssemblyInfo>
<AssemblyName>System.Globalization</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime</AssemblyName>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName>System.Security.SecuritySafeCritical</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Object</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="formatType" Type="System.Type" />
</Parameters>
<Docs>
<param name="formatType">The <see cref="T:System.Type" /> for which to get a formatting object. This method only supports the <see cref="T:System.Globalization.NumberFormatInfo" /> and <see cref="T:System.Globalization.DateTimeFormatInfo" /> types.</param>
<summary>Gets an object that defines how to format the specified type.</summary>
<returns>The value of the <see cref="P:System.Globalization.CultureInfo.NumberFormat" /> property, which is a <see cref="T:System.Globalization.NumberFormatInfo" /> containing the default number format information for the current <see cref="T:System.Globalization.CultureInfo" />, if <paramref name="formatType" /> is the <see cref="T:System.Type" /> object for the <see cref="T:System.Globalization.NumberFormatInfo" /> class.
-or-
The value of the <see cref="P:System.Globalization.CultureInfo.DateTimeFormat" /> property, which is a <see cref="T:System.Globalization.DateTimeFormatInfo" /> containing the default date and time format information for the current <see cref="T:System.Globalization.CultureInfo" />, if <paramref name="formatType" /> is the <see cref="T:System.Type" /> object for the <see cref="T:System.Globalization.DateTimeFormatInfo" /> class.
-or-
null, if <paramref name="formatType" /> is any other object.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
<xref:System.Globalization.CultureInfo.GetFormat%2A> implements <xref:System.IFormatProvider.GetFormat%2A?displayProperty=nameWithType>.
`NumberFormatInfo` provides the culture-specific numeric format used in conjunction with the Format methods in the base data types. `DateTimeFormatInfo` controls how the date and time values are formatted for a specific culture.
]]></format>
</remarks>
<altmember cref="T:System.Type" />
<altmember cref="T:System.Globalization.NumberFormatInfo" />
<altmember cref="T:System.Globalization.DateTimeFormatInfo" />
<altmember cref="P:System.Globalization.CultureInfo.NumberFormat" />
<altmember cref="P:System.Globalization.CultureInfo.DateTimeFormat" />
</Docs>
</Member>
<Member MemberName="GetHashCode">
<MemberSignature Language="C#" Value="public override int GetHashCode ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig virtual instance int32 GetHashCode() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Globalization.CultureInfo.GetHashCode" />
<MemberSignature Language="VB.NET" Value="Public Overrides Function GetHashCode () As Integer" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; override int GetHashCode();" />
<MemberSignature Language="F#" Value="override this.GetHashCode : unit -&gt; int" Usage="cultureInfo.GetHashCode " />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Globalization</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime</AssemblyName>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2">
<AttributeName>System.Runtime.TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Int32</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<summary>Serves as a hash function for the current <see cref="T:System.Globalization.CultureInfo" />, suitable for hashing algorithms and data structures, such as a hash table.</summary>
<returns>A hash code for the current <see cref="T:System.Globalization.CultureInfo" />.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
This method overrides <xref:System.Object.GetHashCode%2A?displayProperty=nameWithType>.
This method generates the same hash code for two objects that are equal according to the <xref:System.Globalization.CultureInfo.Equals%2A> method.
]]></format>
</remarks>
<altmember cref="M:System.Object.GetHashCode" />
<altmember cref="T:System.Collections.Hashtable" />
<altmember cref="M:System.Globalization.CultureInfo.Equals(System.Object)" />
</Docs>
</Member>
<Member MemberName="IetfLanguageTag">
<MemberSignature Language="C#" Value="public string IetfLanguageTag { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance string IetfLanguageTag" />
<MemberSignature Language="DocId" Value="P:System.Globalization.CultureInfo.IetfLanguageTag" />
<MemberSignature Language="VB.NET" Value="Public ReadOnly Property IetfLanguageTag As String" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; property System::String ^ IetfLanguageTag { System::String ^ get(); };" />
<MemberSignature Language="F#" Value="member this.IetfLanguageTag : string" Usage="System.Globalization.CultureInfo.IetfLanguageTag" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime</AssemblyName>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Globalization</AssemblyName>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netframework-4.8">
<AttributeName>System.Runtime.InteropServices.ComVisible(false)</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Docs>
<summary>Deprecated. Gets the RFC 4646 standard identification for a language.</summary>
<value>A string that is the RFC 4646 standard identification for a language.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
> [!NOTE]
> This property and the <xref:System.Globalization.CultureInfo.GetCultureInfoByIetfLanguageTag%2A> method are deprecated. Instead, you should use a the <xref:System.Globalization.CultureInfo.Name%2A?displayProperty=nameWithType> property. IETF tags and names are identical.
The RFC 4646 standard that is maintained by the Internet Engineering Task Force (IETF) defines an IETF language tag, which provides a uniform means of identifying a language. The format of an IETF language tag is similar to the culture name returned by the <xref:System.Globalization.CultureInfo.Name%2A> property, but does not identify a culture uniquely. That is, different cultures share the same IETF language tag if those cultures have identical linguistic characteristics. The linguistic characteristics of a culture are contained in the <xref:System.Globalization.TextInfo> object associated with a <xref:System.Globalization.CultureInfo> object.
An IETF language tag consists of a mandatory language identifier, an optional script identifier, and an optional region identifier.
For more information, see [RFC 5646, "Tags for Identifying Languages](https://go.microsoft.com/fwlink/?LinkId=230876). For a list of subtags, see [The IANA Language Subtag Registry](https://go.microsoft.com/fwlink/?LinkId=230877).
]]></format>
</remarks>
<altmember cref="P:System.Globalization.CultureInfo.TextInfo" />
<altmember cref="T:System.Globalization.CultureAndRegionInfoBuilder" />
</Docs>
</Member>
<Member MemberName="InstalledUICulture">
<MemberSignature Language="C#" Value="public static System.Globalization.CultureInfo InstalledUICulture { get; }" />
<MemberSignature Language="ILAsm" Value=".property class System.Globalization.CultureInfo InstalledUICulture" />
<MemberSignature Language="DocId" Value="P:System.Globalization.CultureInfo.InstalledUICulture" />
<MemberSignature Language="VB.NET" Value="Public Shared ReadOnly Property InstalledUICulture As CultureInfo" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; static property System::Globalization::CultureInfo ^ InstalledUICulture { System::Globalization::CultureInfo ^ get(); };" />
<MemberSignature Language="F#" Value="member this.InstalledUICulture : System.Globalization.CultureInfo" Usage="System.Globalization.CultureInfo.InstalledUICulture" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime</AssemblyName>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Globalization</AssemblyName>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Globalization.CultureInfo</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets the <see cref="T:System.Globalization.CultureInfo" /> that represents the culture installed with the operating system.</summary>
<value>The <see cref="T:System.Globalization.CultureInfo" /> that represents the culture installed with the operating system.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
In a localized operating system, such as a Japanese edition of Windows, this property returns the culture of the operating system. This property is the equivalent of `GetSystemDefaultUILanguage` in the Windows API.
]]></format>
</remarks>
<altmember cref="T:System.Resources.ResourceManager" />
<altmember cref="P:System.Globalization.CultureInfo.CurrentCulture" />
<altmember cref="P:System.Globalization.CultureInfo.CurrentUICulture" />
<altmember cref="P:System.Globalization.CultureInfo.InvariantCulture" />
<altmember cref="P:System.Globalization.CultureInfo.Parent" />
</Docs>
</Member>
<Member MemberName="InvariantCulture">
<MemberSignature Language="C#" Value="public static System.Globalization.CultureInfo InvariantCulture { get; }" />
<MemberSignature Language="ILAsm" Value=".property class System.Globalization.CultureInfo InvariantCulture" />
<MemberSignature Language="DocId" Value="P:System.Globalization.CultureInfo.InvariantCulture" />
<MemberSignature Language="VB.NET" Value="Public Shared ReadOnly Property InvariantCulture As CultureInfo" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; static property System::Globalization::CultureInfo ^ InvariantCulture { System::Globalization::CultureInfo ^ get(); };" />
<MemberSignature Language="F#" Value="member this.InvariantCulture : System.Globalization.CultureInfo" Usage="System.Globalization.CultureInfo.InvariantCulture" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Globalization</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime</AssemblyName>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2">
<AttributeName>get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Globalization.CultureInfo</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets the <see cref="T:System.Globalization.CultureInfo" /> object that is culture-independent (invariant).</summary>
<value>The object that is culture-independent (invariant).</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The invariant culture is culture-insensitive; it is associated with the English language but not with any country/region. You specify the invariant culture by name by using an empty string ("") in the call to a <xref:System.Globalization.CultureInfo> instantiation method. <xref:System.Globalization.CultureInfo.InvariantCulture%2A?displayProperty=nameWithType> also retrieves an instance of the invariant culture. It can be used in almost any method in the <xref:System.Globalization> namespace that requires a culture. The objects returned by properties such as <xref:System.Globalization.CultureInfo.CompareInfo%2A>, <xref:System.Globalization.CultureInfo.DateTimeFormat%2A>, and <xref:System.Globalization.CultureInfo.NumberFormat%2A> also reflect the string comparison and formatting conventions of the invariant culture.
Unlike culture-sensitive data, which is subject to change by user customization or by updates to the .NET Framework or the operating system, invariant culture data is stable over time and across installed cultures and cannot be customized by users. This makes the invariant culture particularly useful for operations that require culture-independent results, such as formatting and parsing operations that persist formatted data, or sorting and ordering operations that require that data be displayed in a fixed order regardless of culture.
## String Operations
You can use the invariant culture for culture-sensitive string operations that are not affected by the conventions of the current thread culture and that are consistent across cultures. For example, you may want sorted data to appear in a fixed order or apply a standard set of casing conventions to strings regardless of the current thread culture. To do this, you pass the <xref:System.Globalization.CultureInfo.InvariantCulture%2A> object to a method that has a <xref:System.Globalization.CultureInfo> parameter, such as <xref:System.String.Compare%28System.String%2CSystem.String%2CSystem.Boolean%2CSystem.Globalization.CultureInfo%29> and <xref:System.String.ToUpper%28System.Globalization.CultureInfo%29>.
## Persisting Data
The <xref:System.Globalization.CultureInfo.InvariantCulture%2A> property can be used to persist data in a culture-independent format. This provides a known format that does not change and that can be used to serialize and deserialize data across cultures. After the data is deserialized, it can be formatted appropriately based on the cultural conventions of the current user.
For example, if you choose to persist date and time data in string form, you can pass the <xref:System.Globalization.CultureInfo.InvariantCulture%2A> object to the <xref:System.DateTime.ToString%28System.String%2CSystem.IFormatProvider%29?displayProperty=nameWithType> or <xref:System.DateTimeOffset.ToString%28System.IFormatProvider%29?displayProperty=nameWithType> method to create the string, and you can pass the <xref:System.Globalization.CultureInfo.InvariantCulture%2A> object to the <xref:System.DateTime.Parse%28System.String%2CSystem.IFormatProvider%29?displayProperty=nameWithType> or <xref:System.DateTimeOffset.Parse%28System.String%2CSystem.IFormatProvider%2CSystem.Globalization.DateTimeStyles%29?displayProperty=nameWithType> method to convert the string back to a date and time value. This technique ensures that the underlying date and time values do not change when the data is read or written by users from different cultures.
The following example uses the invariant culture to persist a <xref:System.DateTime> value as a string. It then parses the string and displays its value by using the formatting conventions of the French (France) and German (Germany) cultures.
[!code-csharp[System.Globalization.CultureInfo.InvariantCulture#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.globalization.cultureinfo.invariantculture/cs/persist1.cs#1)]
[!code-vb[System.Globalization.CultureInfo.InvariantCulture#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.cultureinfo.invariantculture/vb/persist1.vb#1)]
## Security Decisions
If you are making a security decision (such as whether to allow access to a system resource) based on the result of a string comparison or a case change, you should not use the invariant culture. Instead, you should perform a case-sensitive or case-insensitive ordinal comparison by calling a method that includes a <xref:System.StringComparison> parameter and supplying either <xref:System.StringComparison.Ordinal?displayProperty=nameWithType> or <xref:System.StringComparison.OrdinalIgnoreCase?displayProperty=nameWithType> as an argument. Code that performs culture-sensitive string operations can cause security vulnerabilities if the current culture is changed or if the culture on the computer that is running the code differs from the culture that is used to test the code. In contrast, an ordinal comparison depends solely on the binary value of the compared characters.
]]></format>
</remarks>
<altmember cref="P:System.Globalization.CultureInfo.CurrentCulture" />
<altmember cref="P:System.Globalization.CultureInfo.CurrentUICulture" />
<altmember cref="P:System.Globalization.CultureInfo.InstalledUICulture" />
<altmember cref="P:System.Globalization.CultureInfo.Parent" />
<altmember cref="P:System.Globalization.CultureInfo.IsNeutralCulture" />
</Docs>
</Member>
<Member MemberName="IsNeutralCulture">
<MemberSignature Language="C#" Value="public virtual bool IsNeutralCulture { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance bool IsNeutralCulture" />
<MemberSignature Language="DocId" Value="P:System.Globalization.CultureInfo.IsNeutralCulture" />
<MemberSignature Language="VB.NET" Value="Public Overridable ReadOnly Property IsNeutralCulture As Boolean" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; virtual property bool IsNeutralCulture { bool get(); };" />
<MemberSignature Language="F#" Value="member this.IsNeutralCulture : bool" Usage="System.Globalization.CultureInfo.IsNeutralCulture" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Globalization</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime</AssemblyName>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets a value indicating whether the current <see cref="T:System.Globalization.CultureInfo" /> represents a neutral culture.</summary>
<value>
<see langword="true" /> if the current <see cref="T:System.Globalization.CultureInfo" /> represents a neutral culture; otherwise, <see langword="false" />.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
A neutral culture is a culture that is associated with a language but not with a country or region. It differs from a specific culture, which is a culture that is associated with both a language and a country or region. For example, fr is the name for the neutral French culture, while fr-FR is the name for the French culture in France.
If this property returns `false`, the culture is either a specific culture or the invariant culture.
## Examples
The following code example determines which cultures using the Chinese language are neutral cultures.
> [!NOTE]
> The example displays the older zh-CHS and zh-CHT culture names with the 0x0004 and 0x7C04 culture identifiers, respectively. However, your Windows Vista applications should use the zh-Hans name instead of zh-CHS and the zh-Hant name instead of zh-CHT. The zh-Hans and zh-Hant names represent the current standard, and should be used unless you have a reason for using the older names.
[!code-cpp[System.Globalization.CultureInfo.IsNeutralCulture2#1](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.IsNeutralCulture2/CPP/neutralculture.cpp#1)]
[!code-csharp[System.Globalization.CultureInfo.IsNeutralCulture2#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.IsNeutralCulture2/CS/neutralculture.cs#1)]
[!code-vb[System.Globalization.CultureInfo.IsNeutralCulture2#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CultureInfo.IsNeutralCulture2/VB/neutralculture.vb#1)]
]]></format>
</remarks>
<altmember cref="P:System.Globalization.CultureInfo.InvariantCulture" />
</Docs>
</Member>
<Member MemberName="IsReadOnly">
<MemberSignature Language="C#" Value="public bool IsReadOnly { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance bool IsReadOnly" />
<MemberSignature Language="DocId" Value="P:System.Globalization.CultureInfo.IsReadOnly" />
<MemberSignature Language="VB.NET" Value="Public ReadOnly Property IsReadOnly As Boolean" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; property bool IsReadOnly { bool get(); };" />
<MemberSignature Language="F#" Value="member this.IsReadOnly : bool" Usage="System.Globalization.CultureInfo.IsReadOnly" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Globalization</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime</AssemblyName>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets a value indicating whether the current <see cref="T:System.Globalization.CultureInfo" /> is read-only.</summary>
<value>
<see langword="true" /> if the current <see cref="T:System.Globalization.CultureInfo" /> is read-only; otherwise, <see langword="false" />. The default is <see langword="false" />.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
If the <xref:System.Globalization.CultureInfo> is read-only, the <xref:System.Globalization.CultureInfo.DateTimeFormat%2A> and <xref:System.Globalization.CultureInfo.NumberFormat%2A> instances are also read-only.
## Examples
The following code example shows that <xref:System.Globalization.CultureInfo.IsReadOnly%2A> also helps protect the <xref:System.Globalization.DateTimeFormatInfo> and <xref:System.Globalization.NumberFormatInfo> instances associated with the <xref:System.Globalization.CultureInfo>.
[!code-cpp[System.Globalization.CultureInfo.ReadOnly#1](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.ReadOnly/CPP/yslin_cultureinfo_readonly.cpp#1)]
[!code-csharp[System.Globalization.CultureInfo.ReadOnly#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.ReadOnly/CS/yslin_cultureinfo_readonly.cs#1)]
[!code-vb[System.Globalization.CultureInfo.ReadOnly#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CultureInfo.ReadOnly/VB/yslin_cultureinfo_readonly.vb#1)]
]]></format>
</remarks>
<altmember cref="M:System.Globalization.CultureInfo.ReadOnly(System.Globalization.CultureInfo)" />
</Docs>
</Member>
<Member MemberName="KeyboardLayoutId">
<MemberSignature Language="C#" Value="public virtual int KeyboardLayoutId { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance int32 KeyboardLayoutId" />
<MemberSignature Language="DocId" Value="P:System.Globalization.CultureInfo.KeyboardLayoutId" />
<MemberSignature Language="VB.NET" Value="Public Overridable ReadOnly Property KeyboardLayoutId As Integer" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; virtual property int KeyboardLayoutId { int get(); };" />
<MemberSignature Language="F#" Value="member this.KeyboardLayoutId : int" Usage="System.Globalization.CultureInfo.KeyboardLayoutId" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime</AssemblyName>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Globalization</AssemblyName>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netframework-4.8">
<AttributeName>System.Runtime.InteropServices.ComVisible(false)</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Int32</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets the active input locale identifier.</summary>
<value>A 32-bit signed number that specifies an input locale identifier.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The input locale identifier was formerly called the keyboard layout. An input locale identifier is a broader concept than a keyboard layout since it can also indicate a speech-to-text converter, an Input Method Editor (IME), or any other form of input.
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="LCID">
<MemberSignature Language="C#" Value="public virtual int LCID { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance int32 LCID" />
<MemberSignature Language="DocId" Value="P:System.Globalization.CultureInfo.LCID" />