CultureInfo.Name 属性

定义

获取格式为 languagecode2-country/regioncode2 的区域性名称。Gets the culture name in the format languagecode2-country/regioncode2.

public:
 virtual property System::String ^ Name { System::String ^ get(); };
public virtual string Name { get; }
member this.Name : string
Public Overridable ReadOnly Property Name As String

属性值

如果当前 CultureInfo 与区域性相关,则格式为为 languagecode2-country/regioncode2的区域性名称;如果是固定的区域性,则为空字符串。The culture name in the format languagecode2-country/regioncode2, if the current CultureInfo is culture-dependent; or an empty string, if it's an invariant culture. languagecode2 是派生自 ISO 639-1 的小写双字母代码。languagecode2 is a lowercase two-letter code derived from ISO 639-1. country/regioncode2 派生自 ISO 3166,一般包含两个大写字母,或一个 BCP-47 语言标记。country/regioncode2 is derived from ISO 3166 and usually consists of two uppercase letters, or a BCP-47 language tag.

示例

下面的代码示例显示非特定区域性的几个属性。The following code example displays several properties of the neutral cultures.

备注

该示例分别显示带有0x0004 和0x7C04 区域性标识符的较早 zh-chs-CHS 和 zh-chs CHT 区域性名称。The example displays the older zh-CHS and zh-CHT culture names with the 0x0004 and 0x7C04 culture identifiers, respectively. 但是,Windows Vista 应用程序应使用 zh-chs-Hans 名称而不是 zh-chs 和 zh-chs-zh-hant 名称,而不是 zh-chs-CHT。However, your Windows Vista applications should use the zh-Hans name instead of zh-CHS and the zh-Hant name instead of zh-CHT. Zh-chs-Hans 和 zh-chs-Zh-hant 名称表示当前标准,除非你有使用旧名称的原因,否则应该使用。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.

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

注解

有关 Name 属性可以在 Windows 系统上返回的预定义区域性名称和标识符的列表,请参阅windows 支持的语言/区域名称列表中的语言标记列。For a list of predefined culture names and identifiers that the Name property can return on Windows systems, see the Language tag column in the list of language/region names supported by Windows. 列名遵循 BCP 47 定义的标准。Culture names follow the standard defined by BCP 47. 此外,从 Windows 10 开始,name 可以是任何有效的 BCP-47 语言标记。In addition, starting with Windows 10, name can be any valid BCP-47 language tag. 请注意,区域性名称可能会发生更改,并且它们还可以反映自定义区域性的名称。Note that culture names are subject to change, and that they also can reflect the names of custom cultures.

CultureInfo.Name 属性遵循 CultureInfo 类主题中提供的命名标准。The CultureInfo.Name property follows the naming standards provided in the CultureInfo class topic. 它返回区域性名称的缩写形式,该名称不包括任何替换排序顺序的指示。It returns the short form of the culture name that excludes any indication of an alternate sort order. 例如,如果使用字符串 "de DE_phoneb" 来实例化 CultureInfo 对象以反映替换排序顺序,则 Name 属性返回 "de"。For example, if you instantiate a CultureInfo object by using the string "de-DE_phoneb" to reflect an alternate sort order, the Name property returns "de-DE".

若要获取区域性的完整名称,应使用 DisplayNameEnglishNameNativeName 属性。To get the full name of the culture, you should use the DisplayName, EnglishName, or NativeName property.

适用于

另请参阅