我想通过 c# 代码访问国家、州和引用名称。到目前为止,我已通过 CultureInfo 类成功访问了国家名称,我的国家名称代码:
public string[] Get()
{
Dictionary<string, string> CountryNameDictonary = new Dictionary<string, string>();
foreach (System.Globalization.CultureInfo ci in System.Globalization.CultureInfo.GetCultures(System.Globalization.CultureTypes.SpecificCultures))
{
System.Globalization.RegionInfo ri = new System.Globalization.RegionInfo(ci.Name);
if (!CountryNameDictonary.ContainsKey(ri.EnglishName))
{
CountryNameDictonary.Add(ri.EnglishName, ri.TwoLetterISORegionName);
}
}
var OrderedNames = CountryNameDictonary.OrderBy(p => p.Key);
Dictionary<string, string> Countries = new Dictionary<string, string>();
foreach (KeyValuePair<string, string> val in OrderedNames)
{
Countries.Add(val.Key, val.Value);
}
return Countries.Keys.ToArray();
}
现在我被困住了,不知道如何访问州和引用名称。我希望以最简单的方式列出每个选定国家/地区的州和城市列表,而无需返回编辑数据源(数据库或 XML) .我该怎么做,请帮忙?