His writing is list1. RemoveAll (m=& gt; List2. FindIndex (n=& gt; N.n ame==m.n ame) & gt; 0);
Found only remove 1 row, want to know how to write better,
Then see a take the intersection method, var list=list1. Where ((x, I)=& gt; List2. FindIndex (z=& gt; Z.n ame==x.n ame)==I). ToList (); This method is to obtain the intersection, egg ache is look not to understand the function of the parameters, I ask you
CodePudding user response:
List1. RemoveAll (m=& gt; List2. The.findall (n=& gt; N.n ame==m.n ame)) this sentence don't know if you want as a result,Linq and many more can't understand things, come on!
CodePudding user response:
//merge + to heavy
List1. Concat (list2). Distinct () ToList ();
//intersection
List1. Intersects (list2). ToList ();
//difference set, remove list1 with list2 element in the
List1. Except (list2). ToList ();
CodePudding user response:
Var list=list1. Where ((x, I)=& gt; List2. FindIndex (z=& gt; Z.n ame==x.n ame)==I). ToList ();X is the element of list1
I is an element of subscript
If of the same element with list2 list1 subscript, this code should be unable to get to the intersection
CodePudding user response:
You move the mouse, I will know thatCodePudding user response: