Get Culture names in the .NET Framework


This example shows how to get all culture names in the .NET Framework.

Use static method CultureInfo.Get­Cultures. To get associated specific culture use static method CultureInfo.Cre­ateSpecificCul­ture.

Following code is modified MSDN example (it’s just sorted by culture name).
sourcecode language=”csharp”]
// get culture names
List<string> list = new List<string>();
foreach (CultureInfo ci in CultureInfo.GetCultures(CultureTypes.AllCultures))
{
string specName = “(none)”;
try
{
specName = CultureInfo.CreateSpecificCulture(ci.Name).Name;
}
catch { }
list.Add(String.Format(“{0,-12}{1,-12}{2}”, ci.Name, specName, ci.EnglishName));
}

list.Sort();  // sort by name

// write to console
Console.WriteLine(“CULTURE   SPEC.CULTURE  ENGLISH NAME”);
Console.WriteLine(“————————————————————–“);
foreach (string str in list)
Console.WriteLine(str);
[/sourcecode]

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s