Export (0) Print
Expand All
0 out of 1 rated this helpful - Rate this topic

CultureInfo.GetCultures Method

Gets the list of supported cultures filtered by the specified CultureTypes.

[Visual Basic]
Public Shared Function GetCultures( _
   ByVal types As CultureTypes _
) As CultureInfo()
[C#]
public static CultureInfo[] GetCultures(
 CultureTypes types
);
[C++]
public: static CultureInfo* GetCultures(
 CultureTypes types
) [];
[JScript]
public static function GetCultures(
   types : CultureTypes
) : CultureInfo[];

Parameters

types
A combination of CultureTypes values that filter the cultures to retrieve.

Return Value

An array of type CultureInfo that represents the supported cultures filtered by the specified CultureTypes values.

Remarks

Setting types to the SpecificCultures value returns all specific cultures only. Setting types to the NeutralCultures value returns all neutral cultures and the invariant culture. Setting types to the AllCultures value returns all specific cultures, all neutral cultures, and the invariant culture.

Example

[Visual Basic, C#, C++] The following code example displays several properties of the neutral cultures.

[Visual Basic] 
Imports System
Imports System.Globalization

Public Class SamplesCultureInfo

   Public Shared Sub Main()

      ' Displays several properties of the neutral cultures.
      Console.WriteLine("CULTURE ISO ISO WIN DISPLAYNAME                              ENGLISHNAME")
      Dim ci As CultureInfo
      For Each ci In  CultureInfo.GetCultures(CultureTypes.NeutralCultures)
         Console.Write("{0,-7}", ci.Name)
         Console.Write(" {0,-3}", ci.TwoLetterISOLanguageName)
         Console.Write(" {0,-3}", ci.ThreeLetterISOLanguageName)
         Console.Write(" {0,-3}", ci.ThreeLetterWindowsLanguageName)
         Console.Write(" {0,-40}", ci.DisplayName)
         Console.WriteLine(" {0,-40}", ci.EnglishName)
      Next ci

   End Sub 'Main 

End Class 'SamplesCultureInfo


'This code produces the following output.  This output has been cropped for brevity.
'
'CULTURE ISO ISO WIN DISPLAYNAME                              ENGLISHNAME
'ar      ar  ara ARA Arabic                                   Arabic
'bg      bg  bul BGR Bulgarian                                Bulgarian
'ca      ca  cat CAT Catalan                                  Catalan
'zh-CHS  zh  zho CHS Chinese (Simplified)                     Chinese (Simplified)
'zh-CHT  zh  zho CHT Chinese (Traditional)                    Chinese (Traditional)
'cs      cs  ces CSY Czech                                    Czech
'da      da  dan DAN Danish                                   Danish
'de      de  deu DEU German                                   German
'el      el  ell ELL Greek                                    Greek
'en      en  eng ENU English                                  English
'es      es  spa ESP Spanish                                  Spanish
'fi      fi  fin FIN Finnish                                  Finnish


[C#] 
using System;
using System.Globalization;

public class SamplesCultureInfo  {

   public static void Main()  {

      // Displays several properties of the neutral cultures.
      Console.WriteLine( "CULTURE ISO ISO WIN DISPLAYNAME                              ENGLISHNAME" );
      foreach ( CultureInfo ci in CultureInfo.GetCultures( CultureTypes.NeutralCultures ) )  {
         Console.Write( "{0,-7}", ci.Name );
         Console.Write( " {0,-3}", ci.TwoLetterISOLanguageName );
         Console.Write( " {0,-3}", ci.ThreeLetterISOLanguageName );
         Console.Write( " {0,-3}", ci.ThreeLetterWindowsLanguageName );
         Console.Write( " {0,-40}", ci.DisplayName );
         Console.WriteLine( " {0,-40}", ci.EnglishName );
      }

   }

}


/*
This code produces the following output.  This output has been cropped for brevity.

CULTURE ISO ISO WIN DISPLAYNAME                              ENGLISHNAME
ar      ar  ara ARA Arabic                                   Arabic
bg      bg  bul BGR Bulgarian                                Bulgarian
ca      ca  cat CAT Catalan                                  Catalan
zh-CHS  zh  zho CHS Chinese (Simplified)                     Chinese (Simplified)
zh-CHT  zh  zho CHT Chinese (Traditional)                    Chinese (Traditional)
cs      cs  ces CSY Czech                                    Czech
da      da  dan DAN Danish                                   Danish
de      de  deu DEU German                                   German
el      el  ell ELL Greek                                    Greek
en      en  eng ENU English                                  English
es      es  spa ESP Spanish                                  Spanish
fi      fi  fin FIN Finnish                                  Finnish

*/

[C++] 
#using <mscorlib.dll>
using namespace System;
using namespace System::Globalization;

int main()  {

   // Displays several properties of the neutral cultures.
   Console::WriteLine( S"CULTURE ISO ISO WIN DISPLAYNAME                              ENGLISHNAME" );
   System::Collections::IEnumerator* enum0 = CultureInfo::GetCultures(CultureTypes::NeutralCultures)->GetEnumerator();
   while (enum0->MoveNext())
   {
      CultureInfo* ci = __try_cast<CultureInfo*>(enum0->Current);
      Console::Write( S"{0,-7}", ci->Name );
      Console::Write( S" {0,-3}", ci->TwoLetterISOLanguageName );
      Console::Write( S" {0,-3}", ci->ThreeLetterISOLanguageName );
      Console::Write( S" {0,-3}", ci->ThreeLetterWindowsLanguageName );
      Console::Write( S" {0,-40}", ci->DisplayName );
      Console::WriteLine( S" {0,-40}", ci->EnglishName );
   }

}


/*
This code produces the following output.  This output has been cropped for brevity.

CULTURE ISO ISO WIN DISPLAYNAME                              ENGLISHNAME
ar      ar  ara ARA Arabic                                   Arabic
bg      bg  bul BGR Bulgarian                                Bulgarian
ca      ca  cat CAT Catalan                                  Catalan
zh-CHS  zh  zho CHS Chinese (Simplified)                     Chinese (Simplified)
zh-CHT  zh  zho CHT Chinese (Traditional)                    Chinese (Traditional)
cs      cs  ces CSY Czech                                    Czech
da      da  dan DAN Danish                                   Danish
de      de  deu DEU German                                   German
el      el  ell ELL Greek                                    Greek
en      en  eng ENU English                                  English
es      es  spa ESP Spanish                                  Spanish
fi      fi  fin FIN Finnish                                  Finnish

*/

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

CultureInfo Class | CultureInfo Members | System.Globalization Namespace | CultureTypes

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.