广

ASP编程

  • IOS开发
  • android开发
  • PHP编程
  • JavaScript
  • ASP.NET
  • ASP编程
  • JSP编程
  • Java编程
  • 易语言
  • Ruby编程
  • Perl编程
  • AJAX
  • 正则表达式
  • C语言
  • 编程开发

    在webservice中传递Hashtable

    2018-04-03 21:36:19 次阅读 稿源:互联网
    零七广告

      烈火网(LieHuo.Net)教程 webservice中不支持hashtable的数据类型,那么如何在webservice中传递hashtable呢?我们可以通过将hashtable转化为webservice中支持的数组的类型来进行传递,在调用的时候再转换成hashtable就可以了。

    以下为引用的内容:
    [WebMethod]
    public DictionaryEntry[] SetValue()
    {
    Hashtable sl = new Hashtable();
    sl.Add("kiss", "me");
    sl.Add("love", "you");
    DictionaryEntry[] array = new DictionaryEntry[sl.Count];
    sl.CopyTo(array, 0);
    return array;
    }
    调用webservice中的方法

    using System;
    using System.Data;
    using System.Configuration;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using System.Collections;
    using SourceCode;
    using localhost;
    public partial class _Default : System.Web.UI.Page
    {
    protected void Page_Load(object sender, EventArgs e)
    {
    if (!IsPostBack)
    {
    getHashTable();
    }
    }

    private void getHashTable()
    {
    Hashtable obj = new Hashtable();
    localhost.WebService test = new localhost.WebService();
    localhost.DictionaryEntry[] entries = (localhost.DictionaryEntry[])test.SetValue();
    foreach (localhost.DictionaryEntry entry in entries)
    {
    obj.Add(entry.Key, entry.Value);
    }
    foreach (System.Collections.DictionaryEntry each in obj)
    {
    Response.Write(each.Key.ToString() + "=" + each.Value.ToString() + "<br/>");
    }

    }
    }

      转自:http://www.cnblogs.com/emperoryong/

    零七网部分新闻及文章转载自互联网,供读者交流和学习,若有涉及作者版权等问题请及时与我们联系,以便更正、删除或按规定办理。感谢所有提供资讯的网站,欢迎各类媒体与零七网进行文章共享合作。

    零七广告
    零七广告
    零七广告
    零七广告