CultureInfo.IsNeutralCulture Właściwość

Definicja

Pobiera wartość wskazującą, czy bieżący CultureInfo reprezentuje kulturę neutralną.

public:
 virtual property bool IsNeutralCulture { bool get(); };
public virtual bool IsNeutralCulture { get; }
member this.IsNeutralCulture : bool
Public Overridable ReadOnly Property IsNeutralCulture As Boolean

Wartość właściwości

true jeśli bieżący CultureInfo reprezentuje kulturę neutralną; w przeciwnym razie false.

Przykłady

Poniższy przykład kodu określa, które kultury używające języka chińskiego są kulturami neutralnymi.

Uwaga

W przykładzie są wyświetlane nazwy starszych zh-CHS i zh-CHT kultur z odpowiednio identyfikatorami kultury 0x0004 i 0x7C04. Jednak aplikacje systemu Windows Vista powinny używać zh-Hans nazwy zamiast zh-CHS i zh-Hant nazwy zamiast zh-CHT. Nazwy zh-Hans i zh-Hant reprezentują bieżący standard i powinny być używane, chyba że masz powód używania starszych nazw.

using namespace System;
using namespace System::Globalization;
int main()
{
   
   // Lists the cultures that use the Chinese language and determines if each is a neutral culture.
   System::Collections::IEnumerator^ enum0 = CultureInfo::GetCultures( CultureTypes::AllCultures )->GetEnumerator();
   while ( enum0->MoveNext() )
   {
      CultureInfo^ ci = safe_cast<CultureInfo^>(enum0->Current);
      if ( ci->TwoLetterISOLanguageName->Equals( "zh" ) )
      {
         Console::Write( "{0,-7} {1,-40}", ci->Name, ci->EnglishName );
         if ( ci->IsNeutralCulture )
         {
            Console::WriteLine( ": neutral" );
         }
         else
         {
            Console::WriteLine( ": specific" );
         }
      }
   }
}

/*
This code produces the following output.

zh-Hans Chinese (Simplified)                    : neutral
zh-TW   Chinese (Traditional, Taiwan)           : specific
zh-CN   Chinese (Simplified, PRC)               : specific
zh-HK   Chinese (Traditional, Hong Kong S.A.R.) : specific
zh-SG   Chinese (Simplified, Singapore)         : specific
zh-MO   Chinese (Traditional, Macao S.A.R.)     : specific
zh      Chinese                                 : neutral
zh-Hant Chinese (Traditional)                   : neutral
zh-CHS  Chinese (Simplified) Legacy             : neutral
zh-CHT  Chinese (Traditional) Legacy            : neutral

*/
using System;
using System.Globalization;

public class SamplesCultureInfo
{

   public static void Main()
   {

      // Lists the cultures that use the Chinese language and determines if each is a neutral culture.
      foreach (CultureInfo ci in CultureInfo.GetCultures(CultureTypes.AllCultures))
      {
         if (ci.TwoLetterISOLanguageName == "zh")
         {
            Console.Write("{0,-7} {1,-40}", ci.Name, ci.EnglishName);
            if (ci.IsNeutralCulture)
            {
               Console.WriteLine(": neutral");
                }
            else
            {
               Console.WriteLine(": specific");
            }
         }
      }
   }
}


/*
This code produces the following output.

zh-Hans Chinese (Simplified)                    : neutral
zh-TW   Chinese (Traditional, Taiwan)           : specific
zh-CN   Chinese (Simplified, PRC)               : specific
zh-HK   Chinese (Traditional, Hong Kong S.A.R.) : specific
zh-SG   Chinese (Simplified, Singapore)         : specific
zh-MO   Chinese (Traditional, Macao S.A.R.)     : specific
zh      Chinese                                 : neutral
zh-Hant Chinese (Traditional)                   : neutral
zh-CHS  Chinese (Simplified) Legacy             : neutral
zh-CHT  Chinese (Traditional) Legacy            : neutral

*/
Imports System.Globalization

Module Module1

   Public Sub Main()

      ' Lists the cultures that use the Chinese language and determines if each is a neutral culture.
      Dim ci As CultureInfo
      For Each ci In CultureInfo.GetCultures(CultureTypes.AllCultures)
         If ci.TwoLetterISOLanguageName = "zh" Then
            Console.Write("{0,-7} {1,-40}", ci.Name, ci.EnglishName)
            If ci.IsNeutralCulture Then
               Console.WriteLine(": neutral")
            Else
               Console.WriteLine(": specific")
            End If
         End If
      Next ci

   End Sub

End Module


'This code produces the following output.
'
'zh-Hans Chinese (Simplified)                    : neutral
'zh-TW   Chinese (Traditional, Taiwan)           : specific
'zh-CN   Chinese (Simplified, PRC)               : specific
'zh-HK   Chinese (Traditional, Hong Kong S.A.R.) : specific
'zh-SG   Chinese (Simplified, Singapore)         : specific
'zh-MO   Chinese (Traditional, Macao S.A.R.)     : specific
'zh      Chinese                                 : neutral
'zh-Hant Chinese (Traditional)                   : neutral
'zh-CHS  Chinese (Simplified) Legacy             : neutral
'zh-CHT  Chinese (Traditional) Legacy            : neutral

Uwagi

Neutralna kultura to kultura skojarzona z językiem, ale nie z krajem lub regionem. Różni się od konkretnej kultury, która jest kulturą skojarzona zarówno z językiem, jak i krajem lub regionem. Na przykład fr jest nazwą neutralnej kultury francuskiej, a fr-FR jest nazwą francuskiej kultury we Francji.

Jeśli ta właściwość zwróci falsewartość , kultura jest konkretną kulturą lub niezmienną kulturą.

Dotyczy

Zobacz też