Freigeben über


CultureInfo.IsNeutralCulture Property

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

Gets a value indicating whether the current CultureInfo object represents a neutral culture.

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

Syntax

'Declaration
Public Overridable ReadOnly Property IsNeutralCulture As Boolean
public virtual bool IsNeutralCulture { get; }

Property Value

Type: System.Boolean
true if the current CultureInfo object represents a neutral culture; otherwise, false.

Remarks

If this property returns false, the culture is either a specific culture or the invariant culture.

Examples

The following example determines which cultures using the Chinese language are neutral cultures.

Imports System.Globalization

Public Class Example

   Public Shared Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock)
      outputBlock.FontFamily = New System.Windows.Media.FontFamily("Courier New")

      ' 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" }

      ' Determine if each culture is a neutral culture.
      For Each cultureName As String In cultureNames
         Dim ci As New CultureInfo(cultureName)
         outputBlock.Text += String.Format("{0,-7} {1,-40}", ci.Name, ci.EnglishName)
         If ci.IsNeutralCulture Then
            outputBlock.Text &= ": neutral" & vbCrLf
         Else
            outputBlock.Text &= ": specific" & vbCrLf
         End If
      Next
   End Sub
End Class
'  This example produces the following output.
'    zh-CN   Chinese (People's Republic of China)    : specific
'    zh-Hans Chinese                                 : neutral
'    zh-Hant Chinese                                 : neutral
'    zh-HK   Chinese (Hong Kong S.A.R.)              : specific
'    zh-MO  Chinese (Macao S.A.R.)                   : specific
'    zh-SG  Chinese (Singapore)                      : specific
'    zh-TW  Chinese (Taiwan)                         : specific
using System;
using System.Globalization;

public class Example
{

   public static void Demo(System.Windows.Controls.TextBlock outputBlock)
   {
      outputBlock.FontFamily = new System.Windows.Media.FontFamily("Courier New");

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

      // Determine if each culture is a neutral culture.
      foreach (string cultureName in cultureNames)
      {
         CultureInfo ci = new CultureInfo(cultureName);

         outputBlock.Text += String.Format("{0,-7} {1,-40}", ci.Name, ci.EnglishName);
         if (ci.IsNeutralCulture)
               outputBlock.Text += ": neutral" + "\n";
         else
               outputBlock.Text += ": specific" + "\n";
      }

   }

}
/*
This example produces the following output.
   zh-CN   Chinese (People's Republic of China)    : specific
   zh-Hans Chinese                                 : neutral
   zh-Hant Chinese                                 : neutral
   zh-HK   Chinese (Hong Kong S.A.R.)              : specific
   zh-MO  Chinese (Macao S.A.R.)                   : specific
   zh-SG  Chinese (Singapore)                      : specific
   zh-TW  Chinese (Taiwan)                         : specific
*/

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.