Created
June 4, 2012 13:14
-
-
Save Dynyx/2868297 to your computer and use it in GitHub Desktop.
Country list
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
namespace Sandbox | |
{ | |
public class Country | |
{ | |
public string Name { get; set; } | |
public string ThreeLetterAbbr { get; set; } | |
public string TwoLetterAbbr { get; set; } | |
} | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var countryList = GetAllCountries(); | |
} | |
public static IEnumerable<Country> GetAllCountries() | |
{ | |
var countries = CultureInfo.GetCultures(CultureTypes.SpecificCultures) | |
.Select(ci => new RegionInfo(ci.LCID)) | |
.Select(ri => new Country | |
{ | |
Name = ri.EnglishName, | |
ThreeLetterAbbr = ri.TwoLetterISORegionName, | |
TwoLetterAbbr = ri.ThreeLetterISORegionName | |
}).ToList(); | |
return countries; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment