CultureInfo.Parent 屬性

定義

取得 CultureInfo,代表目前 CultureInfo 的父文化特性。

public:
 virtual property System::Globalization::CultureInfo ^ Parent { System::Globalization::CultureInfo ^ get(); };
public virtual System.Globalization.CultureInfo Parent { get; }
member this.Parent : System.Globalization.CultureInfo
Public Overridable ReadOnly Property Parent As CultureInfo

屬性值

CultureInfo,代表目前 CultureInfo 的父文化特性。

範例

下列程式碼範例會使用中文來判斷每個特定文化特性的父文化特性。

注意

此範例會分別顯示具有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()
{
   
   // Prints the header.
   Console::WriteLine( "SPECIFIC CULTURE                                     PARENT CULTURE" );
   
   // Determines the specific cultures that use the Chinese language, 
   // and displays the parent culture.
   System::Collections::IEnumerator^ en = CultureInfo::GetCultures( CultureTypes::SpecificCultures )->GetEnumerator();
   while ( en->MoveNext() )
   {
      CultureInfo^ ci = safe_cast<CultureInfo^>(en->Current);
      if ( ci->TwoLetterISOLanguageName->Equals( "zh" ) )
      {
         Console::Write( "0x{0} {1} {2,-40}", ci->LCID.ToString(  "X4" ), ci->Name, ci->EnglishName );
         Console::WriteLine( "0x{0} {1} {2}", ci->Parent->LCID.ToString( "X4" ), ci->Parent->Name, ci->Parent->EnglishName );
      }
   }
}

/*
This code produces the following output.

SPECIFIC CULTURE                                     PARENT CULTURE
0x0404 zh-TW Chinese (Traditional, Taiwan)           0x7C04 zh-CHT Chinese (Traditional) Legacy
0x0804 zh-CN Chinese (Simplified, PRC)               0x0004 zh-CHS Chinese (Simplified) Legacy
0x0C04 zh-HK Chinese (Traditional, Hong Kong S.A.R.) 0x7C04 zh-CHT Chinese (Traditional) Legacy
0x1004 zh-SG Chinese (Simplified, Singapore)         0x0004 zh-CHS Chinese (Simplified) Legacy
0x1404 zh-MO Chinese (Traditional, Macao S.A.R.)     0x7C04 zh-CHT Chinese (Traditional) Legacy

*/
using System;
using System.Globalization;

public class SamplesCultureInfo
{

   public static void Main()
   {

      // Prints the header.
      Console.WriteLine("SPECIFIC CULTURE                                     PARENT CULTURE");

      // Determines the specific cultures that use the Chinese language, and displays the parent culture.
      foreach (CultureInfo ci in CultureInfo.GetCultures(CultureTypes.SpecificCultures))
      {
         if (ci.TwoLetterISOLanguageName == "zh")
         {
            Console.Write("0x{0} {1} {2,-40}", ci.LCID.ToString("X4"), ci.Name, ci.EnglishName);
            Console.WriteLine("0x{0} {1} {2}", ci.Parent.LCID.ToString("X4"), ci.Parent.Name, ci.Parent.EnglishName);
         }
      }
   }
}

/*
This code produces the following output.

SPECIFIC CULTURE                                     PARENT CULTURE
0x0404 zh-TW Chinese (Traditional, Taiwan)           0x7C04 zh-CHT Chinese (Traditional) Legacy
0x0804 zh-CN Chinese (Simplified, PRC)               0x0004 zh-CHS Chinese (Simplified) Legacy
0x0C04 zh-HK Chinese (Traditional, Hong Kong S.A.R.) 0x7C04 zh-CHT Chinese (Traditional) Legacy
0x1004 zh-SG Chinese (Simplified, Singapore)         0x0004 zh-CHS Chinese (Simplified) Legacy
0x1404 zh-MO Chinese (Traditional, Macao S.A.R.)     0x7C04 zh-CHT Chinese (Traditional) Legacy

*/
Imports System.Globalization

Module Module1

    Public Sub Main()

      ' Prints the header.
        Console.WriteLine("SPECIFIC CULTURE                                     PARENT CULTURE")

        ' Determines the specific cultures that use the Chinese language, and displays the parent culture.
        Dim ci As CultureInfo
        For Each ci In CultureInfo.GetCultures(CultureTypes.SpecificCultures)
            If ci.TwoLetterISOLanguageName = "zh" Then
                Console.Write("0x{0} {1} {2,-40}", ci.LCID.ToString("X4"), ci.Name, ci.EnglishName)
                Console.WriteLine("0x{0} {1} {2}", ci.Parent.LCID.ToString("X4"), ci.Parent.Name, ci.Parent.EnglishName)
            End If
        Next ci

    End Sub



'This code produces the following output.
'
'SPECIFIC CULTURE                                     PARENT CULTURE
'0x0404 zh-TW Chinese (Traditional, Taiwan)           0x7C04 zh-CHT Chinese (Traditional) Legacy
'0x0804 zh-CN Chinese (Simplified, PRC)               0x0004 zh-CHS Chinese (Simplified) Legacy
'0x0C04 zh-HK Chinese (Traditional, Hong Kong S.A.R.) 0x7C04 zh-CHT Chinese (Traditional) Legacy
'0x1004 zh-SG Chinese (Simplified, Singapore)         0x0004 zh-CHS Chinese (Simplified) Legacy
'0x1404 zh-MO Chinese (Traditional, Macao S.A.R.)     0x7C04 zh-CHT Chinese (Traditional) Legacy

End Module

備註

文化特性具有階層,其中特定文化特性的父系是中性文化特性、中性文化特性的父系是 InvariantCulture ,而 的 InvariantCulture 父系則是非變異文化特性本身。 父文化特性只包含其子系之間通用的資訊集。

如果系統中無法使用特定文化特性的資源,則會使用中性文化特性的資源。 如果中性文化特性的資源無法使用,則會使用內嵌在主要元件中的資源。 如需資源後援程式的詳細資訊,請參閱 封裝和部署資源

適用於

另請參閱