How to get the country code from CultureInfo?

后端 未结 5 2062
面向向阳花
面向向阳花 2021-01-01 10:17

I have the following:

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

var a = c.DisplayName;
var b = c.EnglishName;
va         


        
5条回答
  •  醉酒成梦
    2021-01-01 10:44

    System.Globalization.CultureInfo c = new System.Globalization.CultureInfo("en-GB");
    var ri = new RegionInfo(c.Name);
    string countryName = ri.DisplayName;
    

    That will give you:

    "United Kingdom"
    

    For Two Letter Use:

    string countryAbbrivation = ri.TwoLetterISORegionName;
    

    That will give you "GB"

提交回复
热议问题