out类类型数组

来源:互联网 发布:微赞淘宝客浏览器失败 编辑:程序博客网 时间:2024/04/29 01:02

类:

[Serializable]    public class WeixinResult    {        private string _id = string.Empty;        public string Id        {            get { return _id; }            set { _id = value; }        }        private string _result = string.Empty;        public string Result        {            get { return _result; }            set { _result = value; }        }    }


实现(由于之前没写info[i] = new WeixinResult();纠结了好久!=。=):

 public string ShowFlightNo(string weixin_id,out WeixinResult[] info)        {                DataSet ds = m.GetFlightNo2(str);                            info = new WeixinResult[ds.Tables[0].Rows.Count];                 for (int i = 0; i < ds.Tables[0].Rows.Count; i++)                {                    DataRow dr = ds.Tables[0].Rows[i];                    info[i] = new WeixinResult();                    info[i].Id= Convert.ToString(dr["flight_id"]);                    info[i].Result = Convert.ToString(dr["flight_no"]) + "," + Convert.ToString(dr["std"]);                }                 Msg = "可:";            }            return Msg;                    }

0 0