Looking for a way to select from multiple lists where values exists in all lists.
public class A {
public List<B> BList {get;set;}
}
public class B {
public string Key {get;set;}
public List<int> IntegerList {get;set;}
}
Given the following input I would like to retrieve the integers that exist in all lists.
method(){
List<int> list1 = new List<int>{ 1, 2, 3, 4, 5, 6};
List<int> list2 = new List<int>{ 1, 2, 3 };
List<int> list3 = new List<int>{ 1, 2 };
var a = new A();
a.BList = new List<B>{ new B { Key = "b1", IntegerList = list1,
new B { Key = "b2", IntegerList = list2
new B { Key = "b3", IntegerList = list3 }
}
I basically want to be able to retrieve a new list { 1,2 } given an infinite number of integer lists, since these values appear in all.