CultureInfo.Parent 屬性

定義

取得 CultureInfo,代表目前 CultureInfo 的父文化特性。Gets the CultureInfo that represents the parent culture of the current 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 的父文化特性。The CultureInfo that represents the parent culture of the current CultureInfo.

範例

下列程式碼範例會使用中文語言來判斷每個特定文化特性的父文化特性。The following code example determines the parent culture of each specific culture using the Chinese language.

注意

這個範例顯示舊的 zh-CHS 和 zh-CHT 文化特性名稱,其文化特性識別項分別是 0x0004 和 0x7C04。The example displays the older zh-CHS and zh-CHT culture names with the 0x0004 and 0x7C04 culture identifiers, respectively. 不過,您的 Windows Vista 應用程式應該使用 zh-Hans 名稱,而不是 zh-CHS 和 zh-Zh-hant 名稱,而不是 zh-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-Hans 和 zh-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()
{
   
   // 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 的父系則是不因文化特性而異。The cultures have a hierarchy in which the parent of a specific culture is a neutral culture, the parent of a neutral culture is the InvariantCulture, and the parent of the InvariantCulture is the invariant culture itself. 父系文化特性只包含其子系中通用的一組資訊。The parent culture encompasses only the set of information that is common among its children.

如果系統不提供特定文化特性的資源,則會使用中性文化特性的資源。If the resources for the specific culture are not available in the system, the resources for the neutral culture are used. 如果無法使用中性文化特性的資源,則會使用內嵌在主要元件中的資源。If the resources for the neutral culture are not available, the resources embedded in the main assembly are used. 如需資源回退程式的詳細資訊,請參閱封裝和部署資源For more information on the resource fallback process, see Packaging and Deploying Resources.

適用於

另請參閱