清风小溪 2018-12-01 05:47 采纳率: 0%
浏览 2414

C# 通过linq语句删除符合条件的datatable中的行,语句怎样写

var q = from c in dt77.AsEnumerable()
where c.Field("行号") == Convert.ToInt32(temp4.Rows[k]["行号"])
select c;

  • 写回答

4条回答

  • threenewbee 2018-12-01 05:55
    关注

    你这么写好,然后foreach删除,或者,把条件取反,得到的查询结果就是删除后的。

    var q = from c in dt77.AsEnumerable()
    where c.Field("行号") != Convert.ToInt32(temp4.Rows[k]["行号"])
    select c;
    此时q就是排除了这个条件之后的数据

    评论

报告相同问题?