Home > Net >  C # the realization of the function of the List
C # the realization of the function of the List

Time:04-26

List A is A, b, d, e,
List B is a, B, c, d, f

To achieve a C, a, b, C, d, e, f

How to implement?

CodePudding user response:

Baidu
Linq and difference and complement
Do it again, all the 4 90% of the things you can do

The remaining 10% is left connection, connection (cartesian), selectmany this

CodePudding user response:

C # Linq intersection and set, difference set to heavy

List ListA=new List (a);
List By=new List (a);
List ListResult=new List (a);




ListResult=ListA. Distinct (.) ToList ();//to heavy
ListResult=ListA. Except (by). ToList ();//difference set
ListResult=ListA. Union (by). ToList ();//and set
ListResult=ListA. Intersects (by). ToList ();//intersection

CodePudding user response:

Diy, than ask who I useful
  •  Tags:  
  • C#
  • Related