c# - Select distinct objects from a List<Object> -


this question has answer here:

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

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -