共用方式為


CultureInfo.Name 屬性

定義

取得 languagecode2country/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國家/地區代碼2- 格式的文化特性名稱;如果是不因文化特性而異,則為空字串。 languagecode2 是 ISO 639-1 中所定義的小寫雙字母代碼,如果沒有兩個字母代碼,則為 ISO 639-3 中所定義的三個字母代碼。 country/regioncode2 包含 ISO 3166 中定義的值,通常由兩個大寫字母或 BCP-47 語言標記所組成。

範例

下列程式代碼範例會顯示中性文化特性的數個屬性。

注意

此範例會分別顯示具有0x0004和0x7C04文化特性標識碼的較舊 zh-CHS 和文化 zh-CHT 特性名稱。 不過,您的 Windows Vista 應用程式應該使用 zh-Hans 名稱,而不是 zh-CHS 名稱 zh-Hant ,而不是 zh-CHT。 zh-Hanszh-Hant 名稱代表目前的標準,除非您有使用舊名稱的原因,否則應該使用 。

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

備註

如需屬性可以在 Windows 系統上傳回之預先定義文化特性名稱和標識子Name的清單,請參閱 Windows 支援的語言/區域名稱清單中的語言標記數據行。 文化名稱遵循 BCP 47 定義的標準。 此外,從 Windows 10 開始, name 可以是任何有效的 BCP-47 語言標記。 請注意,文化特性名稱可能會變更,而且也可以反映自定義文化特性的名稱。

屬性 CultureInfo.Name 遵循類別主題中 CultureInfo 提供的命名標準。 它會傳回文化特性名稱的簡短形式,以排除任何替代排序順序的指示。 例如,如果您使用字串 「de-DE_phoneb」 來具現化 CultureInfo 物件,以反映替代的排序順序,則 屬性會 Name 傳回 「de-DE」。

若要取得文化特性的完整名稱,您應該使用 DisplayNameEnglishNameNativeName 屬性。

適用於

另請參閱