Thursday, August 9, 2012

All regions and all timezones

Getting a list of all regions.


using System.Globalization;
                    
var cultures = new Dictionary<string, string>();
foreach (CultureInfo cultureInfo in CultureInfo.GetCultures(CultureTypes.SpecificCultures))
{
       var currRegion = new RegionInfo(cultureInfo.Name);
       if (!cultures.ContainsKey(currRegion.EnglishName))
       {
              cultures.Add(currRegion.EnglishName, currRegion.Name);
       }
}


Getting a list of all timezones.

using System.Collections.ObjectModel;

ReadOnlyCollection<TimeZoneInfo> timeZones = TimeZoneInfo.GetSystemTimeZones(); 

No comments: