DataTable, How to conditionally delete rows

前端 未结 4 940
时光取名叫无心
时光取名叫无心 2020-11-30 00:05

I\'m engaged in a C# learning process and it is going well so far. I however just now hit my first \"say what?\" moment.

The DataTable offers random row access to it

4条回答
  •  失恋的感觉
    2020-11-30 00:42

    Here's a one-liner using LINQ and avoiding any run-time evaluation of select strings:

    someDataTable.Rows.Cast().Where(
        r => r.ItemArray[0] == someValue).ToList().ForEach(r => r.Delete());
    

提交回复
热议问题