C#动态数组实用实例解析
C#动态数组(ArrayList )应用可以说在C#开发中是十分常用的,那么具体的实用实例是如何实现的呢?具体的实现步骤和注意事项是什么呢?
下面就是一个C#动态数组实例:用绑定一个DataList的三层代码
C#动态数组之DAL 数据访问层代码:
//绑定IDList,显示所有人员列表 public DataSet SelectIDListAll() { string Str = "select p_number,p_name from t_people"; DataSet ds = new DataSet(); myCon = new SqlConnection(DAL.DALConfig.ConnectionString); try { SqlDataAdapter mycomm = new SqlDataAdapter(Str,myCon); mycomm.Fill(ds,"t_people"); return ds; } catch(Exception exc) { throw exc; } }
C#动态数组之BLL业务层代码:
//绑定IDList,显示所有人员列表 public ArrayList SelectIDListAll() { DAL.TPeopleDao peopledao = new TPeopleDao(); DataSet ds = new DataSet(); ds = peopledao.SelectIDListAll(); // Creates and initializes a new ArrayList. ArrayList myAL = new ArrayList(); for(int i=0;i<ds.Tables[0].Rows.Count;i++) { myAL.Add(ds.Tables[0].Rows[i][0].ToString() + " " +ds.Tables[0].Rows[i][1].ToString() ); } return myAL; }
C#动态数组之页面层代码:
相关推荐
TyrionZK 2020-07-04
chensen 2020-11-14
leihui00 2020-09-16
二十不悔三十而立 2020-08-19
shining0 2020-08-02
TyrionZK 2020-07-26
TreasureZ 2020-07-26
natloc 2020-07-19
Bonrui编程路 2020-07-18
TyrionZK 2020-07-18
TreasureZ 2020-06-25
TreasureZ 2020-06-20
TreasureZ 2020-06-16
jameszgw 2020-06-14
Bonrui编程路 2020-06-13
Bonrui编程路 2020-06-07