0
我有一个返回KeyValuePair的WCF Web服务。即:来自WCF的KeyValuePair - 通过ASP.Net消费时的转换错误
List<KeyVauePair<string,int>>
当我测试这在WCF测试客户端,它说的返回类型为:
System.Collections.Generic.KeyValuePair<System.Collections.Generic.KeyValuePair<System.String,System.Int32>>
因此多数民众赞成好,花花公子。然后我去消耗通过在ASP.Net这个Web方法:
List<KeyValuePair<string, int>> testkv = WCF.GetOptionSetValues("contact", "types");
但是,这并不工作,编译器说:
无法隐式转换类型System.Collections.Generic.KeyValuePair []以System.Collections.Generic.List System.Collections.Generic.KeyValuePair
出于某种原因,它似乎编译器认为从Web方法的返回类型为:
System.Collections.Generic.KeyValuePair[]
但它不是一个数组。它是一种:
System.Collections.Generic.KeyValuePair
我很奇怪,为什么编译器解释网页的方法KeyValuePair [],而不是KeyValuePair?