Skip to content

Instantly share code, notes, and snippets.

@Dynyx
Created June 4, 2012 13:14
Show Gist options
  • Save Dynyx/2868297 to your computer and use it in GitHub Desktop.
Save Dynyx/2868297 to your computer and use it in GitHub Desktop.
Country list
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