CultureTypes Enum
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Defines the types of culture lists that can be retrieved using the GetCultures(CultureTypes) method.
This enumeration supports a bitwise combination of its member values.
public enum class CultureTypes
[System.Flags]
public enum CultureTypes
[System.Flags]
[System.Serializable]
public enum CultureTypes
[System.Flags]
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public enum CultureTypes
[<System.Flags>]
type CultureTypes =
[<System.Flags>]
[<System.Serializable>]
type CultureTypes =
[<System.Flags>]
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type CultureTypes =
Public Enum CultureTypes
- Inheritance
- Attributes
Fields
AllCultures | 7 | All cultures that are recognized by .NET, including neutral and specific cultures and custom cultures created by the user. On .NET Framework 4 and later versions and .NET Core running on Windows, it includes the culture data available from the Windows operating system. On .NET Core running on Linux and macOS, it includes culture data defined in the ICU libraries. AllCultures is a composite field that includes the NeutralCultures, SpecificCultures, and InstalledWin32Cultures values. |
FrameworkCultures | 64 | This member is deprecated; using this value with GetCultures(CultureTypes) returns neutral and specific cultures shipped with the .NET Framework 2.0. |
InstalledWin32Cultures | 4 | This member is deprecated. All cultures that are installed in the Windows operating system. |
NeutralCultures | 1 | Cultures that are associated with a language but are not specific to a country/region. |
ReplacementCultures | 16 | This member is deprecated. Custom cultures created by the user that replace cultures shipped with the .NET Framework. |
SpecificCultures | 2 | Cultures that are specific to a country/region. |
UserCustomCulture | 8 | This member is deprecated. Custom cultures created by the user. |
WindowsOnlyCultures | 32 | This member is deprecated and is ignored. |
Examples
The following example demonstrates the CultureTypes.AllCultures
enumeration member and the CultureTypes property.
using System;
using System.Globalization;
class Sample
{
public static void Main()
{
// Get and enumerate all cultures.
var allCultures = CultureInfo.GetCultures(CultureTypes.AllCultures);
foreach (var ci in allCultures)
{
// Display the name of each culture.
Console.Write($"{ci.EnglishName} ({ci.Name}): ");
// Indicate the culture type.
if (ci.CultureTypes.HasFlag(CultureTypes.NeutralCultures))
Console.Write(" NeutralCulture");
if (ci.CultureTypes.HasFlag(CultureTypes.SpecificCultures))
Console.Write(" SpecificCulture");
Console.WriteLine();
}
}
}
/*
The following is a portion of the output from this example.
Tajik (tg): NeutralCulture
Tajik (Cyrillic) (tg-Cyrl): NeutralCulture
Tajik (Cyrillic, Tajikistan) (tg-Cyrl-TJ): SpecificCulture
Thai (th): NeutralCulture
Thai (Thailand) (th-TH): SpecificCulture
Tigrinya (ti): NeutralCulture
Tigrinya (Eritrea) (ti-ER): SpecificCulture
Tigrinya (Ethiopia) (ti-ET): SpecificCulture
Tigre (tig): NeutralCulture
Tigre (Eritrea) (tig-ER): SpecificCulture
Turkmen (tk): NeutralCulture
Turkmen (Turkmenistan) (tk-TM): SpecificCulture
Setswana (tn): NeutralCulture
Setswana (Botswana) (tn-BW): SpecificCulture
Setswana (South Africa) (tn-ZA): SpecificCulture
*/
Imports System.Globalization
Module Module1
Public Sub Main()
' Get and enumerate all cultures.
Dim allCultures = CultureInfo.GetCultures(CultureTypes.AllCultures)
For Each ci In allCultures
' Display the name of each culture.
Console.Write($"{ci.EnglishName} ({ci.Name}): ")
' Indicate the culture type.
If ci.CultureTypes.HasFlag(CultureTypes.NeutralCultures) Then
Console.Write(" NeutralCulture")
End If
If ci.CultureTypes.HasFlag(CultureTypes.SpecificCultures) Then
Console.Write(" SpecificCulture")
End If
Console.WriteLine()
Next
End Sub
End Module
' The following is a portion of the output from this example.
' Tajik (tg): NeutralCulture
' Tajik (Cyrillic) (tg-Cyrl): NeutralCulture
' Tajik (Cyrillic, Tajikistan) (tg-Cyrl-TJ): SpecificCulture
' Thai (th): NeutralCulture
' Thai (Thailand) (th-TH): SpecificCulture
' Tigrinya (ti): NeutralCulture
' Tigrinya (Eritrea) (ti-ER): SpecificCulture
' Tigrinya (Ethiopia) (ti-ET): SpecificCulture
' Tigre (tig): NeutralCulture
' Tigre (Eritrea) (tig-ER): SpecificCulture
' Turkmen (tk): NeutralCulture
' Turkmen (Turkmenistan) (tk-TM): SpecificCulture
' Setswana (tn): NeutralCulture
' Setswana (Botswana) (tn-BW): SpecificCulture
' Setswana (South Africa) (tn-ZA): SpecificCulture
The following example displays several properties of the neutral cultures.
using namespace System;
using namespace System::Globalization;
int main()
{
// Displays several properties of the neutral cultures.
Console::WriteLine( "CULTURE ISO ISO WIN DISPLAYNAME ENGLISHNAME" );
System::Collections::IEnumerator^ enum0 = CultureInfo::GetCultures( CultureTypes::NeutralCultures )->GetEnumerator();
while ( enum0->MoveNext() )
{
CultureInfo^ ci = safe_cast<CultureInfo^>(enum0->Current);
Console::Write( "{0,-7}", ci->Name );
Console::Write( " {0,-3}", ci->TwoLetterISOLanguageName );
Console::Write( " {0,-3}", ci->ThreeLetterISOLanguageName );
Console::Write( " {0,-3}", ci->ThreeLetterWindowsLanguageName );
Console::Write( " {0,-40}", ci->DisplayName );
Console::WriteLine( " {0,-40}", ci->EnglishName );
}
}
/*
This code produces the following output. This output has been cropped for brevity.
CULTURE ISO ISO WIN DISPLAYNAME ENGLISHNAME
ar ar ara ARA Arabic Arabic
bg bg bul BGR Bulgarian Bulgarian
ca ca cat CAT Catalan Catalan
zh-Hans zh zho CHS Chinese (Simplified) Chinese (Simplified)
cs cs ces CSY Czech Czech
da da dan DAN Danish Danish
de de deu DEU German German
el el ell ELL Greek Greek
en en eng ENU English English
es es spa ESP Spanish Spanish
fi fi fin FIN Finnish Finnish
zh zh zho CHS Chinese Chinese
zh-Hant zh zho CHT Chinese (Traditional) Chinese (Traditional)
zh-CHS zh zho CHS Chinese (Simplified) Legacy Chinese (Simplified) Legacy
zh-CHT zh zho CHT Chinese (Traditional) Legacy Chinese (Traditional) Legacy
*/
using System;
using System.Globalization;
public class SamplesCultureInfo
{
public static void Main()
{
// Displays several properties of the neutral cultures.
Console.WriteLine("CULTURE ISO ISO WIN DISPLAYNAME ENGLISHNAME");
foreach (CultureInfo ci in CultureInfo.GetCultures(CultureTypes.NeutralCultures))
{
Console.Write("{0,-7}", ci.Name);
Console.Write(" {0,-3}", ci.TwoLetterISOLanguageName);
Console.Write(" {0,-3}", ci.ThreeLetterISOLanguageName);
Console.Write(" {0,-3}", ci.ThreeLetterWindowsLanguageName);
Console.Write(" {0,-40}", ci.DisplayName);
Console.WriteLine(" {0,-40}", ci.EnglishName);
}
}
}
/*
This code produces the following output. This output has been cropped for brevity.
CULTURE ISO ISO WIN DISPLAYNAME ENGLISHNAME
ar ar ara ARA Arabic Arabic
bg bg bul BGR Bulgarian Bulgarian
ca ca cat CAT Catalan Catalan
zh-Hans zh zho CHS Chinese (Simplified) Chinese (Simplified)
cs cs ces CSY Czech Czech
da da dan DAN Danish Danish
de de deu DEU German German
el el ell ELL Greek Greek
en en eng ENU English English
es es spa ESP Spanish Spanish
fi fi fin FIN Finnish Finnish
zh zh zho CHS Chinese Chinese
zh-Hant zh zho CHT Chinese (Traditional) Chinese (Traditional)
zh-CHS zh zho CHS Chinese (Simplified) Legacy Chinese (Simplified) Legacy
zh-CHT zh zho CHT Chinese (Traditional) Legacy Chinese (Traditional) Legacy
*/
Imports System.Globalization
Module Module1
Public Sub Main()
' Displays several properties of the neutral cultures.
Console.WriteLine("CULTURE ISO ISO WIN DISPLAYNAME ENGLISHNAME")
Dim ci As CultureInfo
For Each ci In CultureInfo.GetCultures(CultureTypes.NeutralCultures)
Console.Write("{0,-7}", ci.Name)
Console.Write(" {0,-3}", ci.TwoLetterISOLanguageName)
Console.Write(" {0,-3}", ci.ThreeLetterISOLanguageName)
Console.Write(" {0,-3}", ci.ThreeLetterWindowsLanguageName)
Console.Write(" {0,-40}", ci.DisplayName)
Console.WriteLine(" {0,-40}", ci.EnglishName)
Next ci
End Sub
'This code produces the following output. This output has been cropped for brevity.
'
'CULTURE ISO ISO WIN DISPLAYNAME ENGLISHNAME
'ar ar ara ARA Arabic Arabic
'bg bg bul BGR Bulgarian Bulgarian
'ca ca cat CAT Catalan Catalan
'zh-Hans zh zho CHS Chinese (Simplified) Chinese (Simplified)
'cs cs ces CSY Czech Czech
'da da dan DAN Danish Danish
'de de deu DEU German German
'el el ell ELL Greek Greek
'en en eng ENU English English
'es es spa ESP Spanish Spanish
'fi fi fin FIN Finnish Finnish
'zh zh zho CHS Chinese Chinese
'zh-Hant zh zho CHT Chinese (Traditional) Chinese (Traditional)
'zh-CHS zh zho CHS Chinese (Simplified) Legacy Chinese (Simplified) Legacy
'zh-CHT zh zho CHT Chinese (Traditional) Legacy Chinese (Traditional) Legacy
End Module
Remarks
These culture type values are returned by the CultureInfo.CultureTypes property, and also serve as a filter that limits the cultures returned by the CultureInfo.GetCultures method. For more information on cultures, see CultureInfo.
Generally, you enumerate all cultures by using the CultureTypes.AllCultures
value. This allows enumeration of custom cultures as well as the other culture types.
Note that all CultureTypes
members have been deprecated except for CultureTypes.AllCultures
, CultureTypes.NeutralCultures
, and CultureTypes.SpecificCultures
.
.NET recognizes the following culture types, all of which are included in enumerations returned by the CultureTypes.AllTypes
enumeration member:
Specific cultures, which specify a country/region and a language. The names of these cultures follow RFC 4646. The format is
<languagecode2>-<country/regioncode2>
, where<languagecode2>
is a lowercase two-letter code derived from ISO 639-1, and<country/regioncode2>
is an uppercase two-letter code derived from ISO 3166. For example, "en-US" for English (United States) is a specific culture. Custom specific cultures (that is, cultures that are application- rather than system-defined) can have any user-specified name, not just a standards-compliant one.Neutral cultures, which specify a language without respect to a country/region. The names of neutral cultures consist of the lowercase two-letter code derived from ISO 639-1. For example: "en" (English) is a neutral culture. Custom neutral cultures (that is, cultures that are application- rather than system-defined) can have any user-specified name, not just a two-letter code.
The invariant culture is included in the array of cultures returned by the CultureInfo.GetCultures method that specifies this value.
Custom cultures, which are application-defined cultures. Custom cultures can represent either specific cultures or neutral cultures and can have any application-specified name.
In Windows versions prior to Windows 10, the
UserCustomCulture
value is assigned to custom cultures created by the developer. In Windows 10, theUserCustomCulture
value is also assigned to system cultures that are not backed by a complete set of cultural data and that do not have unique local identifiers. (All cultures of typeUserCustomCulture
share a CultureInfo.LCID value ofLOCALE_CUSTOM_UNSPECIFIED
(0x1000, or 4096)). As a result, theCultureInfo.GetCultures(CultureTypes.UserCustomCulture)
method returns different sets of cultures on different Windows versions.