使用LINQ獲取一個List <>中的項目,這些項目不在另一個List <>中我會假設(shè)有一個簡單的LINQ查詢來執(zhí)行此操作,我只是不確定如何。請參閱下面的代碼段。class Program{
static void Main(string[] args)
{
List<Person> peopleList1 = new List<Person>();
peopleList1.Add(new Person() { ID = 1 });
peopleList1.Add(new Person() { ID = 2 });
peopleList1.Add(new Person() { ID = 3 });
List<Person> peopleList2 = new List<Person>();
peopleList2.Add(new Person() { ID = 1 });
peopleList2.Add(new Person() { ID = 2 });
peopleList2.Add(new Person() { ID = 3 });
peopleList2.Add(new Person() { ID = 4 });
peopleList2.Add(new Person() { ID = 5 });
}}class Person{
public int ID { get; set; }}我想執(zhí)行一個LINQ查詢給我所有peopleList2不在peopleList1這個例子中的人應(yīng)該給我兩個人(ID = 4&ID = 5)
使用LINQ獲取一個List <>中的項目,這些項目不在另一個List <>中
慕婉清6462132
2019-07-31 15:39:07