public class Info
{
public List<string> Projects { get; set; }
public List<string> Schools { get; set; }
public List<string> Locations { get; set; }
public List<string> Interests { get; set; }
public List<string> Hobbies { get; set; }
}
要交叉2个列表,您可以执行此操作:list1.Select(a => a.Projects).Intersect(list2.Select(b => b.Projects));
但是如果你想让第三个对象使用公共字符串,那么可以从前两个对象中说出来呢?
答案 0 :(得分:2)
我能想到的最简单的解决方案是Cascading Intersection
:
var result = Projects.Intersect(Schools)
.Intersect(Locations)
.Intersect(Interests)
.Intersect(Hobbies)
.ToList();