我写了一个返回arraylist的方法,
public ArrayList GetEDMHotelInformation(String sName)
    {
//填充数据///
}然后填充数据,返回arraylist,
然后在另一个地方调用这个方法,但是提示:Cannot convert type 'object[]' to 'System.Collections.ArrayList'我不明白了,我方法返回的是arraylist,怎么在另一个页面实例化的时候就出错,这个怎么解决,?谢谢。。

解决方案 »

  1.   

    不好意思,还有一点问题,我把完整的方法贴出来, public ArrayList GetEDMHotelInformation(String sName)
        {
            ArrayList arrHotellist = new ArrayList();
            mysqldatabase mysql = new mysqldatabase();
            DataSet ds;
            if (!String.IsNullOrEmpty(sName))
            {
                ds = mysql.Select("select * from cm_hotel where htl_name ='" + sName + "' AND sys_deleted<>'Y' ", null);
                if (ds.Tables[0].Rows.Count > 0)
                {
                    arrHotellist.Add(ds.Tables[0].Rows[0]["htl_propertyid"].ToString());
                    arrHotellist.Add(ds.Tables[0].Rows[1]["htl_eat2eat"].ToString());
                    arrHotellist.Add(ds.Tables[0].Rows[2]["htl_allowreservation"].ToString());
                    arrHotellist.Add(ds.Tables[0].Rows[3]["htl_brand"].ToString());
                    arrHotellist.Add(ds.Tables[0].Rows[4]["htl_address"].ToString());
                    arrHotellist.Add(ds.Tables[0].Rows[5]["htl_country"].ToString());
                    arrHotellist.Add(ds.Tables[0].Rows[6]["htl_city"].ToString());
                    arrHotellist.Add(ds.Tables[0].Rows[7]["htl_postcode"].ToString());
                    arrHotellist.Add(ds.Tables[0].Rows[8]["htl_phone"].ToString());
                    arrHotellist.Add(ds.Tables[0].Rows[9]["htl_fax"].ToString());
                    arrHotellist.Add(ds.Tables[0].Rows[10]["htl_email"].ToString());
                    arrHotellist.Add(ds.Tables[0].Rows[11]["htl_website"].ToString());
                    arrHotellist.Add(ds.Tables[0].Rows[12]["htl_brief"].ToString());
                    arrHotellist.Add(ds.Tables[0].Rows[13]["htl_overview"].ToString());
                }
            }
            return arrHotellist;
        }其实我这是做webservice,然后在另一个网站调用,
    我想把arrHotellist中的数据取出来,然后分别赋给,比如说"
    label1的值是arrHotellist.Add(ds.Tables[0].Rows[3]["htl_brand"].ToString())取的值,
    label2的值是arrHotellist.Add(ds.Tables[0].Rows[3]["htl_address"].ToString())取的值,以此类推,我调用页面不知道该如何赋值了,EdmWebReference.Service1 edmservice = new EdmWebReference.Service1();大家帮帮忙,给点方法,谢谢了,
      

  2.   

    你的ArrayList的每一项应该是一行数据的实体对象
    而不是每把数据库每一个值装进这个列表
      

  3.   


    if (ds.Tables[0].Rows.Count > 0)
    {
    foreach (DataRow _row in ds.Tables[0].Rows)
    {
    //数据表对应的模型实体类
    Entity en = new Entity();
    en.PropertyId = row["htl_propertyid"].ToString();
    en.Eat = row["htl_eat2eat"].ToString();
       ......//列表收录该实体,进入下一条数据循环
    arrHotellist.Add(en);
    }
    }
      

  4.   

    还有 entity 没有用过,怎么用啊,是不是要导入什么命名啊? 
      

  5.   

    ArrayList也不能做为webserver的返回值,因为它不支持序列化。 
    可以返回1个dataset然后在webApplication在转为ArrayList 
     
      

  6.   

    ArrayList 换成 List<string>
      

  7.   

    做为webservice的返回值,必须要求其是可序列化的
    [Serializable]