To get all culturenames in C# and VB.NET you can use the following snippet.
Sample C#
private static void Main(string[] args) { var cultureInformations = GetCultureData(); foreach (var cultureInformation in cultureInformations) { Console.WriteLine("Name:{0} ; SpecificName:{1}; FullName:{2}{3}", cultureInformation.Name, cultureInformation.SpecificName, cultureInformation.Fullname, Environment.NewLine); } Console.Read(); } public static List<CultureInformation> GetCultureData() { var cultureInformations = (from cultureInfo in CultureInfo.GetCultures(CultureTypes.AllCultures) let specificName = CultureInfo.CreateSpecificCulture(cultureInfo.Name).Name select new CultureInformation() {Fullname = cultureInfo.EnglishName, Name = cultureInfo.Name, SpecificName = specificName}).ToList(); return cultureInformations.OrderBy(data => data.Name).ToList(); } public sealed class CultureInformation { public string Name { get; set; } public string SpecificName { get; set; } public string Fullname { get; set; } }
Sample VB.NET
Private Shared Sub Main(args As String()) Dim cultureInformations = GetCultureData() For Each cultureInformation As var In cultureInformations Console.WriteLine("Name:{0} ; SpecificName:{1}; FullName:{2}{3}", cultureInformation.Name, cultureInformation.SpecificName, cultureInformation.Fullname, Environment.NewLine) Next Console.Read() End Sub Public Shared Function GetCultureData() As List(Of CultureInformation) Dim cultureInformations = (From cultureInfo In CultureInfo.GetCultures(CultureTypes.AllCultures)Let specificName = CultureInfo.CreateSpecificCulture(cultureInfo__1.Name).NameNew CultureInformation() With { _ Key .Fullname = cultureInfo__1.EnglishName, _ Key .Name = cultureInfo__1.Name, _ Key .SpecificName = specificName _ }).ToList() Return cultureInformations.OrderBy(Function(data) data.Name).ToList() End Function Public NotInheritable Class CultureInformation Public Property Name() As String Get Return m_Name End Get Set m_Name = Value End Set End Property Private m_Name As String Public Property SpecificName() As String Get Return m_SpecificName End Get Set m_SpecificName = Value End Set End Property Private m_SpecificName As String Public Property Fullname() As String Get Return m_Fullname End Get Set m_Fullname = Value End Set End Property Private m_Fullname As String End Class
RT @CodeSnippetsNET: How to get all culturenames in .NET http://t.co/pcMxPl2vHc #csharp #vb #dotnet #programming #code #coding