Remove Item have same key in List C# -
this question has answer here:
- using linq remove elements list<t> 14 answers
i have list<object>
n objects
. in n objects have object have same id
. example list<t> = {t1, t2, t3, t4, t5....,t10}.
assuming that:
t1.id = t5.id
so want remove t5
list
.
who can me plz.
in question: using linq remove objects within list know object duplicates (ex: "bob"), in question, in list, don't know object duplicate before.
using linq objects only:
source = source.groupby(t => t.id).select(g => g.first()).tolist();
Comments
Post a Comment