c# - Select distinct objects from a List<Object> -
this question has answer here:
- get distinct values out of list<object> 5 answers
i have asked rather similar question here. get distinct values out of list<object>
but question not duplicate. similar have stated far duplicate. in other question, getting values using distinct, here getting objects.
but i'm having problems right.
i have list<beam>
defined below:
list<beam> beams = new list<beam>; public class { public double elevation; }
how can distinct objects list<beam>
based on elevation
property?
you can use groupby here:
var distinctbeams = beams .groupby(b => b.elevation) .select(g => g.first()) .tolist();
Comments
Post a Comment