我写了一个返回arraylist的方法,
public ArrayList GetEDMHotelInformation(String sName)
{
//填充数据///
}然后填充数据,返回arraylist,
然后在另一个地方调用这个方法,但是提示:Cannot convert type 'object[]' to 'System.Collections.ArrayList'我不明白了,我方法返回的是arraylist,怎么在另一个页面实例化的时候就出错,这个怎么解决,?谢谢。。
public ArrayList GetEDMHotelInformation(String sName)
{
//填充数据///
}然后填充数据,返回arraylist,
然后在另一个地方调用这个方法,但是提示:Cannot convert type 'object[]' to 'System.Collections.ArrayList'我不明白了,我方法返回的是arraylist,怎么在另一个页面实例化的时候就出错,这个怎么解决,?谢谢。。
{
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();大家帮帮忙,给点方法,谢谢了,
而不是每把数据库每一个值装进这个列表
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);
}
}
可以返回1个dataset然后在webApplication在转为ArrayList
[Serializable]