How to Convert the value in DataTable into a string array in c#

前端 未结 6 1195
灰色年华
灰色年华 2020-12-16 00:26

I have a DataTable that contains a single row. I want to convert this DataTable values into a string array such that i can access the column values of that DataTable through

6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-16 01:18

    If you would like to use System.Data instead of System.LINQ, then you can do something like this.

     List BrandsInDataTable = new List();
     DataTable g = Access._ME_G_BrandsInPop(); 
            if (g.Rows.Count > 0)
            {
                for (int x = 0; x < g.Rows.Count; x++)
                    BrandsInDataTable.Add(g.Rows[x]["Name"].ToString()); 
            }
            else return;
    

提交回复
热议问题