如何返回通用词典中的一个WebService [英] How to Return Generic Dictionary in a WebService

查看:328
本文介绍了如何返回通用词典中的一个WebService的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在C#返回一个字典Web服务,根据搜索:

I want a Web Service in C# that returns a Dictionary, according to a search:

Dictionary<int, string> GetValues(string search) {}

Web服务编译好,但是,当我尝试引用它,我得到以下错误:
不支持,因为它实现IDictionary的。

The Web Service compiles fine, however, when i try to reference it, i get the following error: "is not supported because it implements IDictionary."

¿我可以为了做得到这个工作?不涉及返回一个DataTable任何想法?

¿What can I do in order to get this working?, any ideas not involving return a DataTable?

推荐答案

本文有方法序列化IDictionaries。寻找我注意到的XmlSerializer不会序列,默认情况下实施的IDictionary对象。有没有解决这个办法吗?大约2/3的一路下跌的页面。

This article has a method to serialize IDictionaries. Look for " I've noticed that XmlSerializer won't serialize objects that implement IDictionary by default. Is there any way around this?" about 2/3 the way down the page.

这篇关于如何返回通用词典中的一个WebService的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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