How to get a distinct list from a List of objects?

后端 未结 10 1225
滥情空心
滥情空心 2020-12-24 04:59

I have a List someList.

class MyClass
{
    public int Prop1...
    public int Prop2...
    public int Prop3...
}
10条回答
  •  萌比男神i
    2020-12-24 05:20

    Just use the build-in function DistinctBy of Microsoft Ajax Ultility library like the sample blow:

    First including library

    using Microsoft.Ajax.Utilities;
    

    then

    var distinctList = yourList.DistinctBy(x => x.Prop2).ToList();
    

提交回复
热议问题