Surprisingly, there are loads of great data snippets hidden inside .Net classes. If you've ever found yourself adding localization to your website, you may have come across the CultureInfo Class in .Net. I know that sometimes I have needed to get a list of country ISO codes and have struggled to get a comprehensive list, or I have needed to retrieve the list from a Database containing the names. This can add an extra Database call and could result in extra code maintenance, and possibly a performance hit.
Well, this is where CultureInfo comes to the rescue. Using this Class, you will be able to easily retrieve a list of country names and their ISO codes using built-in .Net code.
Which gives you a list of 128 countries and their region information:
We can then use the RegionInfo Class to retrieve native names, currencies and ISO codes:
This gives you:
You can also retrieve the month names and day names:
Okay, so all of these are in English...what about other languages? You simply need to set the culture and you will be able to see the results in your chosen language.
Another really handy class is the TimeZoneInfo class, it allows you to retrieve a list of time zones along with their names and values natively using .Net. It can be used to represent any time zone in the world.
Whoa! No need to store and maintain a list of cultures, day, month or timezone names any more. Much better!