How to get the country code from CultureInfo?

Miguel Moura picture Miguel Moura · Dec 2, 2013 · Viewed 33.4k times · Source

I have the following:

System.Globalization.CultureInfo c = new System.Globalization.CultureInfo("en-GB");

var a = c.DisplayName;
var b = c.EnglishName;
var d = c.LCID;
var e = c.Name;
var f = c.NativeName;
var g = c.TextInfo;
var h = c.ThreeLetterISOLanguageName;
var i = c.ThreeLetterWindowsLanguageName;
var j = c.TwoLetterISOLanguageName;

None of this gives me the country code, e.g. GB.

Is there a way to get it without string splitting?

Answer

Sriram Sakthivel picture Sriram Sakthivel · Dec 2, 2013
var c = new CultureInfo("en-GB");
var r = new RegionInfo(c.LCID);
string name = r.Name;

Most probably you need to use r.TwoLetterISORegionName property.

string regionName = r.TwoLetterISORegionName;