簡體   English   中英

有沒有想過從一次數據表中讀取一個完整列值並將其存儲在數組列表中?

[英]Is there any idea to read one full column values from once data table and store it in array list?

我嘗試過以下代碼,但它沒有給出正確的值,

ArrayList = outTable.Select("[FILTER_FLAG]").ToList();
//outTable is my data table having values in the column name "FILTER_FLAG"
        DataTable dataTable = new DataTable();

        dataTable.Columns.Add(new DataColumn("ID", typeof(int)));
        dataTable.Columns.Add(new DataColumn("Name", typeof(string)));

        dataTable.Rows.Add(1, "Mike");
        dataTable.Rows.Add(2, "Cris");
        dataTable.Rows.Add(3, "Ann");

        var _selector = dataTable.Rows.Cast<DataRow>().Select(x => x.Field<int>("ID")).ToList();

        ArrayList list = new ArrayList(_selector);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM