c# get country code

C#
var regions = CultureInfo.GetCultures(CultureTypes.SpecificCultures).Select(x => new RegionInfo(x.LCID));
var englishRegion = regions.FirstOrDefault(region => region.EnglishName.Contains("United Kingdom"));
var countryAbbrev = englishRegion.TwoLetterISORegionName;
Source

Also in C#: