Get a list of Country names from the .Net framework

A lot of systems maintain an SQL table of countrynames for that eternal drop-down on the address form. Getting .Net’s countrynames could be a lot easier, though the method seems a little convoluted:

			foreach ( CultureInfo ci in CultureInfo.GetCultures( CultureTypes.InstalledWin32Cultures ) )
				Console.Write( "{0,-7}", ci.Name );
				Console.Write( " {0,-3}", ci.TwoLetterISOLanguageName );
				RegionInfo ri = new RegionInfo(ci.LCID);
				Console.WriteLine( " {0,-40}", ri.EnglishName);
				Console.WriteLine( " {0,-40}", ri.DisplayName);
				Console.WriteLine( " {0,-40}", ri.Name);

There is a lot more information to be had, but these are the basics. Only thing I am missing is the international telephone prefix for the countries, and of course I still have to maintain regions/states, cities and ZIP-codes – wouldn’t it be nice if some international body would maintain these as a web-service, or at least a standardised XML-format.

Posted in C#

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s