I want to intersect 2 lists of objects which have the same types and same properties in it, but the objects in the list got instantiated separatly.
class foo
{
int id;
string name;
public foo(int Id, string Name)
{
id = Id;
name = Name;
}
}
List<foo> listA = new List<foo>() {new foo(1, "A"), new foo(2, "B"), new foo(3, "C")};
List<foo> listB = new List<foo>() {new foo(2, "B"), new foo(3, "C"), new foo(4, "D")};
List<foo> intersect = listA.Intersect(listB).ToList();
foo object B & C are both in listA & listB but when I intersect them I get 0 entrys. I know its because there are not the same object but what do I need to do to get a list with B and C anyways?. What am I missing?