新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
C#動態(tài)數(shù)組實用實例解析
C#動態(tài)數(shù)組(ArrayList )應(yīng)用可以說在C#開發(fā)中是十分常用的,那么具體的實用實例是如何實現(xiàn)的呢?具體的實現(xiàn)步驟和注意事項是什么呢?

蒙城網(wǎng)站建設(shè)公司創(chuàng)新互聯(lián),蒙城網(wǎng)站設(shè)計制作,有大型網(wǎng)站制作公司豐富經(jīng)驗。已為蒙城上千提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\成都外貿(mào)網(wǎng)站建設(shè)公司要多少錢,請找那個售后服務(wù)好的蒙城做網(wǎng)站的公司定做!
下面就是一個C#動態(tài)數(shù)組實例:用綁定一個DataList的三層代碼
C#動態(tài)數(shù)組之DAL 數(shù)據(jù)訪問層代碼:
- //綁定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#動態(tài)數(shù)組之BLL業(yè)務(wù)層代碼:
- //綁定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
- {
- myAL.Add(ds.Tables[0].Rows[i][0].ToString() +
- " " +ds.Tables[0].Rows[i][1].ToString() );
- }
- return myAL;
- }
C#動態(tài)數(shù)組之頁面層代碼:
- //綁定IDList,顯示所有人員列表
- private void SelectIDListAll()
- {
- Lab.BLL.TPeopleBiz peoplebiz = new TPeopleBiz();
- ArrayList myAL = peoplebiz.SelectIDListAll();
- this.P_IDlist.Items.Clear();
- for(int i = 0 ;i
- {
- this.P_IDlist.Items.Add(myAL[i]);
- }
- }
C#動態(tài)數(shù)組的應(yīng)用實例就向你介紹到這里,希望對你了解和學(xué)習C#動態(tài)數(shù)組有所幫助。
本文名稱:C#動態(tài)數(shù)組實用實例解析
本文來源:http://www.5511xx.com/article/djpohhc.html


咨詢
建站咨詢
