CultureTypes 枚举

定义

定义可以使用 GetCultures(CultureTypes) 方法检索的区域性列表的类型。Defines the types of culture lists that can be retrieved using the GetCultures(CultureTypes) method.

此枚举有一个 FlagsAttribute 属性,允许按位组合成员值。

public enum class CultureTypes
[System.Flags]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public enum CultureTypes
type CultureTypes = 
Public Enum CultureTypes
继承
CultureTypes
属性

字段

AllCultures 7

.NET 识别的所有区域性,包括非特定和特定区域性以及用户创建的自定义区域性。All cultures that recognized by .NET, including neutral and specific cultures and custom cultures created by the user.

在 .NET Framework 4 和更高版本以及正在 Windows 上运行的 .NET Core 上,将包括可从 Windows 操作系统获取的区域性数据。On .NET Framework 4 and later versions and .NET Core running on Windows, it includes the culture data available from the Windows operating system. 在正在 Linux 和 macOS 上运行的 .NET Core 上,将包括 ICU 库中定义的区域性数据。On .NET Core running on Linux and macOS, it includes culture data defined in the ICU libraries.

AllCultures 是包括 NeutralCulturesSpecificCulturesInstalledWin32Cultures 值的复合字段。AllCultures is a composite field that includes the NeutralCultures, SpecificCultures, and InstalledWin32Cultures values.

FrameworkCultures 64

此成员已弃用;结合使用此值与 GetCultures(CultureTypes) 可以返回 .NET Framework 2.0 附带的非特定和特定区域性。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. Windows 操作系统中安装的所有区域性。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. 用户创建的自定义区域性,可以替换 .NET Framework 附带的区域性。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.

示例

下面的示例演示CultureTypes.AllCultures枚举成员CultureTypes和属性。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

注解

这些区域性类型值由CultureInfo.CultureTypes属性返回, 也用作筛选器, 该筛选器限制CultureInfo.GetCultures方法返回的区域性。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. 有关区域性的详细信息, 请CultureInfo参阅。For more information on cultures, see CultureInfo.

通常, 使用CultureTypes.AllCultures值枚举所有区域性。Generally, you enumerate all cultures by using the CultureTypes.AllCultures value. 这允许枚举自定义区域性以及其他区域性类型。This allows enumeration of custom cultures as well as the other culture types.

请注意CultureTypes.AllCultures, CultureTypes除、 CultureTypes.NeutralCulturesCultureTypes.SpecificCultures外, 所有成员均已弃用。Note that all CultureTypes members have been deprecated except for CultureTypes.AllCultures, CultureTypes.NeutralCultures, and CultureTypes.SpecificCultures.

.Net 可识别以下区域性类型, 所有这些类型都包含在CultureTypes.AllTypes枚举成员返回的枚举中:.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. 这些区域性的名称遵循 RFC 4646。The names of these cultures follow RFC 4646. 格式为<languagecode2>-<country/regioncode2>, 其中<languagecode2>是派生<country/regioncode2>自 iso 639-1 的小写双字母代码, 是派生自 iso 3166 的大写双字母代码。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. 例如,“en-US”表示英语(美国),是特定区域性。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. 非特定区域性的名称由派生自 ISO 639-1 的小写双字母代码组成。The names of neutral cultures consist of the lowercase two-letter code derived from ISO 639-1. 例如:“en”(英语)是非特定区域性。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.

    固定区域性包含在由CultureInfo.GetCultures指定此值的方法所返回的区域性的数组中。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.

    在 windows 10 之前的 windows 版本中, UserCustomCulture将值分配给开发人员创建的自定义区域性。In Windows versions prior to Windows 10, the UserCustomCulture value is assigned to custom cultures created by the developer. 在 Windows 10 中, UserCustomCulture还将值分配给不受一组完整的区域性数据支持且不具有唯一本地标识符的系统区域性。In Windows 10, the UserCustomCulture 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. (类型UserCustomCulture的所有区域性均CultureInfo.LCID共享值LOCALE_CUSTOM_UNSPECIFIED (0x1000 或 4096))。(All cultures of type UserCustomCulture share a CultureInfo.LCID value of LOCALE_CUSTOM_UNSPECIFIED (0x1000, or 4096)). 因此, 该CultureInfo.GetCultures(CultureTypes.UserCustomCulture)方法将在不同的 Windows 版本上返回不同的区域性集。As a result, the CultureInfo.GetCultures(CultureTypes.UserCustomCulture) method returns different sets of cultures on different Windows versions.

适用于

另请参阅