熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

C# 2維數組的定義

2022-06-13   來源: .NET編程 

  今天偶爾有個東西要用到維數組發現不會搞來搞去搞了半天還是上網google了資料

  總結一下

  定義變量的方法

      private string[] ColumnsList = {
            序號|rowid主帳戶|masteraccount主帳號|childaccount卡號|cardno
            戶名|name客戶號|crmid科目號|stocktype
            原金額|orgincount發生額|currcount新金額|newcount狀態|state
        };
        private string[] dataList = {
            {張三風正常}
            {張三風正常}
            {張三風掛失}
            {張三風注銷}
        };
        遍歷添加到Table中
           DataTable dt = new DataTable();
            for(int i=;i<ColumnsListLength;i++)
            {
                string[] templist = ColumnsList[i]Split(|);
                if (templistLength != ) continue;
                dtColumnsAdd(templist[]Trim() typeof(string));
            }
            dtAcceptChanges();

            for (int i = ; i < ; i++)
            {
                DataRow dr = dtNewRow();
                for(int j=;j<ColumnsListLength;j++)
                {
                    string[] templist = ColumnsList[j]Split(|);
                    if (templistLength != ) continue;
                    dr[templist[]Trim()] = dataList[i j]Trim();
                }
                dtRowsAdd(dr);
            }
            dtAcceptChanges();

  記一下防止以後忘記!


From:http://tw.wingwit.com/Article/program/net/201311/15317.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.