CultureInfo.IsNeutralCulture Properti

Definisi

Mendapatkan nilai yang menunjukkan apakah saat ini CultureInfo mewakili budaya netral.

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

Nilai Properti

true jika saat ini CultureInfo mewakili budaya netral; jika tidak, false.

Contoh

Contoh kode berikut menentukan budaya mana yang menggunakan bahasa Tionghoa adalah budaya netral.

Catatan

Contohnya menampilkan nama yang lebih zh-CHS lama dan zh-CHT budaya dengan pengidentifikasi budaya 0x0004 dan 0x7C04. Namun, aplikasi Windows Vista Anda harus menggunakan zh-Hans nama alih-alih zh-CHS dan zh-Hant nama alih-alih zh-CHT. Nama zh-Hans dan zh-Hant mewakili standar saat ini, dan harus digunakan kecuali Anda memiliki alasan untuk menggunakan nama yang lebih lama.

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

Keterangan

Budaya netral adalah budaya yang terkait dengan bahasa tetapi tidak dengan negara atau wilayah. Ini berbeda dari budaya tertentu, yang merupakan budaya yang terkait dengan bahasa dan negara atau wilayah. Misalnya, fr adalah nama untuk budaya Prancis netral, sedangkan fr-FR adalah nama untuk budaya Prancis di Prancis.

Jika properti ini kembali false, budayanya adalah budaya tertentu atau budaya invarian.

Berlaku untuk

Lihat juga