名单<国家>成为国家[]在整个Web服务 [英] List<Country> becomes Country [] across web service

查看:127
本文介绍了名单<国家>成为国家[]在整个Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Web服务调用时,会返回一个包含多态列出一个结果对象。然而,当我在我的客户端应用程序中添加一个引用,公共领域成为国家的客户端应用程序的数组。如何更改领域中的客户端应用程序列表?

I have a web service that when invoked, returns a Result object that contains a List polymorphically. However, when I add a reference in my client application, the public field becomes an array of Country in the client application. How do I change the field in the client application to List?

public Result GetCountryList()
{
    List<Country> countries = GrabCountryList();
    Result result = new Result();
    result.theResult = countries;
}

这是公共财产

and this is the public property

public object theResult
{
     get {return _theResult; }
     set {_theResult = value;}
}


接受的答案从穆罕默德Aras的:


Accepted answer from Mehmet Aras:

右键单击服务引用,并选择配置参考。在集合类型,选择System.Collection.Generic.List。更新服务引用,它应该是好去。

Right click on the service reference, and select "Configure Reference". Under Collection type, select System.Collection.Generic.List. Update the service reference, and it should be good to go.

感谢马特汉密尔顿的建议,以创建数组一个新的列表。

Thanks to Matt Hamilton for the suggestion to create a new list from the array.

推荐答案

如果您使用的是VS2008,有服务引用设置形式,可以让你控制客户端代理生成一种先进的按钮。在那里,你可以选择集合类型和列表就是其中之一。

If you're using VS2008, there is an advanced button on the service reference settings form that allows you control the client proxy generation. There you can select the collection type and list is among them.

这篇关于名单&LT;国家&GT;成为国家[]在整个Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆