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和zh-CHT0x7C04区域性标识符的旧zh-CHS名称和区域性名称。 但是,Windows Vista 应用程序应使用 zh-Hans 名称而不是 zh-CHSzh-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 父区域性是固定区域性本身。 父区域性仅包含其子级中常见的一组信息。

如果系统中没有特定区域性的资源,则使用非特定区域性的资源。 如果非特定区域性的资源不可用,则使用主程序集中嵌入的资源。 有关资源回退过程的详细信息,请参阅 打包和部署资源

适用于

另请参阅