请看以下内容:
DataTable newTable = new DataTable();
DataColumn colRMID = new DataColumn();
colRMID.DataType = typeof(System.Int32);
colRMID.ColumnName = "RMID";
DataColumn colCpty = new DataColumn();
colCpty.DataType = typeof(System.String);
colCpty.ColumnName = "Cpty";
newTable.Columns.Add(colRMID);
newTable.Columns.Add(colCpty);
DataRow r1 = newTable.NewRow();
r1["RMID"] = 1234;
r1["Cpty"] = "Internal";
newTable.Rows.Add(r1);
DataRow r2 = newTable.NewRow();
r2["RMID"] = 5678;
r2["Cpty"] = "Wales Fargo";
newTable.Rows.Add(r2);
DataRow r3 = newTable.NewRow();
r3["RMID"] = 1234;
r3["Cpty"] = "External";
newTable.Rows.Add(r3);
DataRow r4 = newTable.NewRow();
r4["RMID"] = 9876;
r4["Cpty"] = "Internal";
newTable.Rows.Add(r4);
我想删除“Cpty”=“Internal”的所有重复行(具有相同的“RMID”)。所以我在数据表中的最终输出应该是:
RMID Cpty
5678 "Wales fargo"
1234 "External"
9876 "Internal"
我需要使用 LINQ
谢谢, 阿比纳夫