Looping through a DataTable

前端 未结 4 809
無奈伤痛
無奈伤痛 2021-02-07 03:51

Well. I have a DataTable with multiple columns and multiple rows.

I want to loop through the DataTable dynamically basically the output should look as follows excluding

4条回答
  •  礼貌的吻别
    2021-02-07 04:35

    foreach (DataColumn col in rightsTable.Columns)
    {
         foreach (DataRow row in rightsTable.Rows)
         {
              Console.WriteLine(row[col.ColumnName].ToString());           
         }
    } 
    

提交回复
热议问题