How to get all culture names in the .NET?

Following 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.

Code:
// get all culture names
List list = new List();
foreach (CultureInfo ci in CultureInfo.GetCultures(CultureTypes.AllCultures))
{
  string cultureName = "(none)";
  try { cultureName = CultureInfo.CreateSpecificCulture(ci.Name).Name; } catch { }
  list.Add(String.Format("{0,-10}{1,-10}{2}", ci.Name, cultureName, 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);


Execute the aboe code and get all culture names.

 If you feel this is helpful or you like it, Please share this using share buttons available on page.

Comments

Popular posts from this blog

Auto Scroll in Common Controls

Convert typed library (.tlb) to .net assembly?

Disable close button on form - C#