试图返回KeyValue对

本文关键字:KeyValue 返回 | 更新日期: 2023-09-27 18:15:31

对不起,这里是完整的代码.....我想传回全名和缩写

公共静态字典> CountryStates {get;设置;}

    public CustomerUpdateDemographics()
    {
        if (CountryStates == null)
        {
            using (var service = new IQPWebServiceClient())
            {
                ServicePointManager.ServerCertificateValidationCallback = (sender, cert, chain, erros) => { return true; };
                service.ClientCredentials.UserName.UserName = "";
                service.ClientCredentials.UserName.Password = "";
                var response = service.GetCountryStates();
                if (response.ReturnStatus.StatusCode == 0)
                {
                    CountryStates = new Dictionary<string, List<string>>();
                    foreach (var countryState in response.CountryStates)
                    {
                        if (!CountryStates.ContainsKey(countryState.CountryCode))
                            CountryStates.Add(countryState.CountryCode, new List<string>());
                       CountryStates[countryState.CountryCode].Add(countryState.StateCode);
                    }
                }
           }

试图返回KeyValue对

你想从函数返回两个字符串吗?

KeyValuePair<string, string>将是合适的类型。

list ?

return CountryStates.ToList();