Remove Item have same key in List C# -


this question has answer here:

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

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -