Compartilhar via


CultureInfo.Parent Property

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets the CultureInfo that represents the parent culture of the current CultureInfo.

Namespace:  System.Globalization
Assembly:  mscorlib (in mscorlib.dll)

Syntax

'Declaration
Public Overridable ReadOnly Property Parent As CultureInfo
public virtual CultureInfo Parent { get; }

Property Value

Type: System.Globalization.CultureInfo
The CultureInfo that represents the parent culture of the current CultureInfo.

Remarks

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.

Examples

The following example determines the parent culture of each specific culture that uses the Chinese language.

Imports System.Globalization

Public Class Example

   Public Shared Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock)
      ' Prints the header.
      outputBlock.FontFamily = New System.Windows.Media.FontFamily("Courier New")
      outputBlock.Text &= "SPECIFIC CULTURE                             PARENT CULTURE" & vbCrLf

      ' Create an array of Chinese culture names.
      Dim cultureNames() As String = { "zh-CN", "zh-Hans", "zh-Hant", "zh-HK", _  
                                       "zh-MO", "zh-SG", "zh-TW" }

      ' Determines the specific cultures that use the Chinese language, and displays the parent culture.
      For Each cultureName As String In cultureNames
         Dim ci As New CultureInfo(cultureName) 
         outputBlock.Text &= String.Format("{0,-7} {1,-37}", ci.Name, ci.EnglishName)
         outputBlock.Text &= String.Format("{0,-7} {1}", ci.Parent.Name, ci.Parent.EnglishName) & vbCrLf
      Next 
   End Sub 
End Class 
' This example produces the following output.
'    SPECIFIC CULTURE                             PARENT CULTURE
'    zh-CN   Chinese (People's Republic of China) zh-Hans Chinese 
'    zh-Hans Chinese                                      Invariant Language (Invariant Country)
'    zh-Hant Chinese                                      Invariant Language (Invariant Country)
'    zh-HK   Chinese (Hong Kong S.A.R.)           zh-Hant Chinese 
'    zh-MO   Chinese (Macao S.A.R.)               zh-Hant Chinese 
'    zh-SG   Chinese (Singapore)                  zh-Hans Chinese 
'    zh-TW   Chinese (Taiwan)                     zh-Hant Chinese 
using System;
using System.Globalization;

public class Example
{
   public static void Demo(System.Windows.Controls.TextBlock outputBlock)
   {
      // Displays the header.
      outputBlock.FontFamily = new System.Windows.Media.FontFamily("Courier New");
      outputBlock.Text += "SPECIFIC CULTURE                             PARENT CULTURE" + "\n";

      // Create an array of Chinese culture names.
      string[] cultureNames = { "zh-CN", "zh-Hans", "zh-Hant", "zh-HK",  
                                "zh-MO", "zh-SG", "zh-TW", };

      // Determines the specific cultures that use the Chinese language, and displays the parent culture.
      foreach (string cultureName in cultureNames)
      {
         CultureInfo ci = new CultureInfo(cultureName);
         outputBlock.Text += String.Format("{0,-7} {1,-37}", ci.Name, ci.EnglishName);
         outputBlock.Text += String.Format("{0,-7} {1}\n", ci.Parent.Name, ci.Parent.EnglishName);
      }
   }
}
/*
This example produces the following output.

SPECIFIC CULTURE                             PARENT CULTURE
zh-CN   Chinese (People's Republic of China) zh-Hans Chinese 
zh-Hans Chinese                                      Invariant Language (Invariant Country)
zh-Hant Chinese                                      Invariant Language (Invariant Country)
zh-HK   Chinese (Hong Kong S.A.R.)           zh-Hant Chinese 
zh-MO   Chinese (Macao S.A.R.)               zh-Hant Chinese 
zh-SG   Chinese (Singapore)                  zh-Hans Chinese 
zh-TW   Chinese (Taiwan)                     zh-Hant Chinese 
*/

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.