次の方法で共有


CultureInfo.Parent プロパティ

現在の CultureInfo の親カルチャを表す CultureInfo を取得します。

Public Overridable ReadOnly Property Parent As CultureInfo
[C#]
public virtual CultureInfo Parent {get;}
[C++]
public: __property virtual CultureInfo* get_Parent();
[JScript]
public function get Parent() : CultureInfo;

プロパティ値

現在の CultureInfo の親カルチャを表す CultureInfo

解説

カルチャは階層構造になっています。たとえば、特定のカルチャの親はニュートラル カルチャで、ニュートラル カルチャの親は InvariantCulture となっています。親カルチャは、その子の間で共通する情報セットだけを持ちます。

システム内で特定のカルチャのリソースが利用できない場合は、ニュートラル カルチャのリソースが使用されます。ニュートラル カルチャのリソースが利用できない場合は、メイン アセンブリに埋め込まれているリソースが使用されます。リソース フォールバック処理の詳細については、 リソースのパッケージ化と配置 を参照してください。

Windows API のカルチャの一覧は、.NET Framework のカルチャの一覧と若干異なります。たとえば、カルチャ識別子 0x7C04 のニュートラル カルチャ zh-CHT "繁体字中国語" は Windows API では利用できません。Windows との相互運用 (たとえば、p/invoke 機構を通じた相互運用) が必要な場合は、.NET Framework で定義されている特定のカルチャを使用してください。これにより、同一の LCID で識別される等価な Windows ロケールとの一貫性が確保されます。

使用例

[Visual Basic, C#, C++] 中国語を使用する特定の各カルチャの親カルチャを決定するコードの例を次に示します。

 
Imports System
Imports System.Globalization

Public Class SamplesCultureInfo

   Public Shared 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,-37}", 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 'Main 

End Class 'SamplesCultureInfo

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


[C#] 
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,-37}", 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 (Taiwan)                     0x7C04 zh-CHT Chinese (Traditional)
0x0804 zh-CN Chinese (People's Republic of China) 0x0004 zh-CHS Chinese (Simplified)
0x0C04 zh-HK Chinese (Hong Kong S.A.R.)           0x7C04 zh-CHT Chinese (Traditional)
0x1004 zh-SG Chinese (Singapore)                  0x0004 zh-CHS Chinese (Simplified)
0x1404 zh-MO Chinese (Macau S.A.R.)               0x0004 zh-CHS Chinese (Simplified)

*/

[C++] 
#using <mscorlib.dll>

using namespace System;
using namespace System::Globalization;

int main() {
   // Prints the header.
   Console::WriteLine(S"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 = __try_cast<CultureInfo*>(en->Current);
      if (ci->TwoLetterISOLanguageName->Equals(S"zh"))
      {
         Console::Write(S"0x{0} {1} {2,-37}", ci->LCID.ToString("X4"), 
            ci->Name, ci->EnglishName);
         Console::WriteLine(S"0x{0} {1} {2}", ci->Parent->LCID.ToString(S"X4"), 
            ci->Parent->Name, ci->Parent->EnglishName);
      }
   }
}

/*
This code produces the following output.

SPECIFIC CULTURE                                  PARENT CULTURE
0x0404 zh-TW Chinese (Taiwan)                     0x7C04 zh-CHT Chinese (Traditional)
0x0804 zh-CN Chinese (People's Republic of China) 0x0004 zh-CHS Chinese (Simplified)
0x0C04 zh-HK Chinese (Hong Kong S.A.R.)           0x7C04 zh-CHT Chinese (Traditional)
0x1004 zh-SG Chinese (Singapore)                  0x0004 zh-CHS Chinese (Simplified)
0x1404 zh-MO Chinese (Macau S.A.R.)               0x0004 zh-CHS Chinese (Simplified)

*/

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET

参照

CultureInfo クラス | CultureInfo メンバ | System.Globalization 名前空間 | CultureInfo | CreateSpecificCulture | CurrentCulture | CurrentUICulture | InstalledUICulture | InvariantCulture