且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Get All Cultures in .Net

更新时间:2022-09-09 09:51:40

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// 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);
本文转自敏捷的水博客园博客,原文链接http://www.cnblogs.com/cnblogsfans/archive/2010/03/25/1694988.html如需转载请自行联系原作者

王德水