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

c# - Unity IoC Lifetime per HttpRequest for UserStore -

Change the color of an oval at click in Java AWT -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -