Chris McKee
Chris McKee

Reputation: 4387

Convert ALPHA-2 to ALPHA-3 in C# ASP.net

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.

Upvotes: 4

Views: 1900

Answers (2)

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

Upvotes: 0

jason
jason

Reputation: 241711

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

Upvotes: 11

Related Questions