I have an object like this :
public class myObject
{
public string Name {get; set;}
public string ID {get; set;}
}
I have two lists like this
List<myObject> list1 = new List<myObject>();
list1.Add(new myObject(){Name = Jason, ID = 1});
list1.Add(new myObject(){Name = Jonathan, ID = 2});
list1.Add(new myObject(){Name = Kevin, ID = 3});
List<myObject> list2 = new List<myObject>();
list2.Add(new myObject(){Name = Jennifer, ID = 5});
list2.Add(new myObject(){Name = Samantha, ID = 2});
list2.Add(new myObject(){Name = Lucy, ID = 9});
I want to intersect these two lists by their ID
s. I mean I want to get Jonathan's and Samantha's objects in another list. How can I do that? Thanks.