C#循环DataTable赋值
作者:互联网
DateTime date = DateTime.MinValue;for (int i = 0; i < dt.Rows.Count; i++) { for (int j = 0; j < dt.Columns.Count; j++) { if (dt.Columns[j].ColumnName == "123" || dt.Columns[j].ColumnName == "456") { DateTime.TryParse(dt.Rows[i][j].ToString(), out date); if(date == DateTime.MinValue) dt.Rows[i][j] = ""; else dt.Rows[i][j] = date.ToString("yyyy-MM-dd"); } } }
参阅:http://t.zoukankan.com/szlblog-p-7458020.html
标签:Rows,C#,DateTime,int,date,dt,DataTable,Columns,赋值 来源: https://www.cnblogs.com/dzw159/p/16285544.html