我有 3 个类型的列表cab
。我需要比较 listA
和listB
。如果Car-number
or status
in与 inlistB
相同,listA
那么我必须将该行添加listB
到listC' else add it to
listA . I need to perform that same operation for all rows for
listB`。如何在两个列表上编写 lambda 来执行此操作?
这是我到目前为止的代码:
public class cab
{
public string Name {get;set;}
public string Desc {get;set;}
public int Car_number {get;set;}
public bool status {get;set;}
}
cab c1 = new cab() { Name = "Zen",Desc = "äsdasdf",Car_number= "8832",status="false"};
cab c2 = new cab() { Name = "Ford",Desc = "sdfgedasdf",Car_number= "1132",status="true"};
cab c3 = new cab() { Name = "Swift",Desc = "sdsdf",Car_number= "732",status="true"};
List<cab> listA = new List<cab>();
listA.Add(c1);
listA.Add(c2);
listA.Add(c3);
List<cab> listB = new List<cab>();
cab c4 = new cab() { Name = "Santro",Desc = "iisdasdf",Car_number= "8832",status="false"};
cab c5 = new cab() { Name = "Ritz",Desc = "esddf",Car_number= "132",status="true"};
listB.Add(c4);
listB.Add(c5);
List<cab> listC = new List<cab>();