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.
.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.
SomeAll of the regions you missed are now supported (in newer versions of the .NET Framework and of the operating system).The following code finds all
RegionInfo
that are "reachable" from a specific culture:On my machine right now it gives:
Edit: Updated to what is seen om my Windows 10 (version 1803 "April 2018 Update") machine, .NET Framework 4.7.2.