Advertisement
Willcode4cash

Country list

Aug 14th, 2016
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.95 KB | None | 0 0
  1. namespace Sandbox
  2. {
  3.     public class Country
  4.     {
  5.         public string Name { get; set; }
  6.         public string ThreeLetterAbbr { get; set; }
  7.         public string TwoLetterAbbr { get; set; }
  8.     }
  9.  
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             var countryList = GetAllCountries();
  15.         }
  16.  
  17.         public static IEnumerable<Country> GetAllCountries()
  18.         {
  19.             var countries = CultureInfo.GetCultures(CultureTypes.SpecificCultures)
  20.                 .Select(ci => new RegionInfo(ci.LCID))
  21.                 .Select(ri => new Country
  22.                                   {
  23.                                       Name = ri.EnglishName,
  24.                                       ThreeLetterAbbr = ri.TwoLetterISORegionName,
  25.                                       TwoLetterAbbr = ri.ThreeLetterISORegionName
  26.                                   }).ToList();
  27.             return countries;
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement