DataRow dr=dt.NewRow();
然后依次用dr["列名"]=值;为该行进行赋值
最后将该行添加到datatable中
dt.Rows.Add(dr);
例如:
DataRow newRow;newRow = dt.NewRow();newRow["Product"] = "大话西游";newRow["Version"] = "2.0";newRow["Description"] = "我很喜欢";dt.Rows.Add(newRow);
var dic = dt1.Rows.OfType()
.ToDictionary(
x => x["姓名"].ToString(),
x => (int)x["年龄"]);
foreach (DataRow row in dt2.Rows)
{
string name = row["姓名"].ToString();
row["年龄"] = dic[name];
}