相关疑难解决方法(0)

使用LINQ获取一个List <>中的项目,这些项目不在另一个List <>中

我会假设有一个简单的LINQ查询来执行此操作,我只是不确定如何.请参阅下面的代码段.

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
{ …
Run Code Online (Sandbox Code Playgroud)

c# linq .net-3.5

485
推荐指数
7
解决办法
35万
查看次数

标签 统计

.net-3.5 ×1

c# ×1

linq ×1