Search code examples
c#.netglobalizationregioninfo

.NET RegionInfo class


When I try to create a new RegionInfo with certain ISO 3166 country codes ("BD" for Bangladesh, "SO" for Somalia, "LK" for Sri Lanka), I get an ArgumentException that says it's not recognized.

What's the deal? The Intellisense of RegionInfo(string) says it conforms to ISO 3166, but these country/region codes are not supported?

I don't get it.


Solution

  • .NET doesn't provide all Cultures/Regions out-of-the-box. Note the 'predefined' RegionInfos here: http://msdn.microsoft.com/en-us/library/system.globalization.regioninfo(VS.80).aspx.

    Unfortunately, if you want to use non-predefined Regions, you have to define them yourself. Here's the MSDN how-to: http://msdn.microsoft.com/en-us/library/ms172469(VS.80).aspx.