Question

Is there a quick built in way to convert ALPHA-2 (GB) to ALPHA-3 (GBR) in C# without having to create an array of them all.

Was it helpful?

Solution

// using System.Globalization;
RegionInfo info = new RegionInfo("GB");
string ISOAlpha3 = info.ThreeLetterISORegionName; // ISOAlpha3 == "GBR"

OTHER TIPS

Sorry for bumping an old thread. This do work for GB but RegionInfo will throw an exception for a lot of ALPHA-2 country codes e.g.

new RegionInfo("AF"); // throws an error for Afghanistan
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top