How to loop through the values of a particular column in datatable?

前端 未结 3 719
不思量自难忘°
不思量自难忘° 2021-01-15 01:00

I want to loop through the values of a particular column in datatable? can anyone please give the C# coding?

3条回答
  •  情书的邮戳
    2021-01-15 01:41

    try below Linq based solution

    var values = (from t in dt.AsEnumarable() // dt is your data table
                 select t[ColumnName]).ToList().ForEach(your expression );
    
    
     or try normal way 
    
     foreach(DataRow drow in dt.Rows)
     {
          string value = drow[columnname].ToString();
     }
    

提交回复
热议问题