It appears that there are in fact a large amount of incorrect / incomplete answers on the subject.
There is a web service that you could add and call which may prove to be more up-to-date than the .NET framework itself, but the easiest, fastest and WORKING method of adding countries to a drop-down is to use the method mentioned in this StackOverflow question:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using System.Globalization; | |
public static IEnumerable<string> GetCountryList() | |
{ | |
List<string> cultureList = new List<string>(); | |
CultureInfo[] cultures = CultureInfo.GetCultures(CultureTypes.SpecificCultures); | |
foreach (CultureInfo culture in cultures) | |
{ | |
RegionInfo region = new RegionInfo(culture.LCID); | |
if (!(cultureList.Contains(region.EnglishName))) | |
{ | |
cultureList.Add(region.EnglishName); | |
} | |
} | |
return cultureList; | |
} |
No comments:
Post a Comment