我有两个DataTable
。
distinct
:
+-------+-------+
| host | count |
+-------+-------+
| comp1 | 2 |
+-------+-------+
| comp2 | 3 |
+-------+-------+
| comp3 | 2 |
+-------+-------+
t
:
+----+-------+
| id | host |
+----+-------+
| 1 | comp1 |
+----+-------+
| 2 | comp2 |
+----+-------+
| 3 | comp1 |
+----+-------+
| 4 | comp3 |
+----+-------+
| 5 | comp1 |
+----+-------+
| 6 | comp3 |
+----+-------+
我想删除t
中包含3
表count
列中distinct
小于for (int i = 0; i < distinct.Rows.Count; i++)
{
if (Convert.ToInt32(distinct.Rows[i][1]) < 3)
{
foreach (DataRow row in t.Select())
{
if (row[1].ToString() == distinct.Rows[i][0].ToString())
{
row.Delete();
}
}
}
}
的计算机名的所有行。代码:
t
但它什么都没做。如果我在上面的代码之前和之后比较{{1}}的内容,它就是一样的。我在这里错过了什么?