I have two lists. I want to remove any items from LIST1 that are NOT present in LIST2.
So for example:
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 });
After run list1
should contain only items: with combination operationId = 1
, machineId = 1
AND OperationId = 3
, MachineId =2
.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…