我有两个清单。我想从 LIST1 中删除 LIST2 中不存在的所有项目。
例如:
var list1 = new List<DownloadTask>();
list1.Add(new DownloadTask{ OperationID = 1, MachineID = 1 });
list1.Add(new DownloadTask{ OperationID = 2, MachineID = 1 });
list1.Add(new DownloadTask{ OperationID = 3, MachineID = 1 });
list1.Add(new DownloadTask{ OperationID = 3, MachineID = 2 });
var list2 = new List<DownloadTask>();
list2.Add(new DownloadTask{ OperationID = 1, MachineID = 1 });
list2.Add(new DownloadTask{ OperationID = 3, MachineID = 2 });
运行后list1
应仅包含项目:组合operationId = 1
, machineId = 1
AND OperationId = 3
, MachineId =2
.