I have a List<MyClass> someList.
class MyClass
{
public int Prop1...
public int Prop2...
public int Prop3...
}
I would like to know how to get a new distinct List<MyClass> distinctList from List<MyClass> someList, but only comparing it to Prop2.
Unfortunately there’s no really easy built-in support for this in the framework – but you can use the
DistinctByimplementation I have in MoreLINQ.You’d use:
(You can take just the
DistinctByimplementation. If you’d rather use a Microsoft implementation, I believe there’s something similar in the System.Interactive assembly of Reactive Extensions.)