c# - Having trouble removing duplicates in List<class> -


i have class , list:

    public class classname     {         public string firstparam { get; set; }         public string secondparam { get; set; }     }      public static list<classname> listname = new list<classname>(); 

the list includes (for example):

apple    banana corn     celery corn     celery corn     grapes raisins  pork 

i trying edit list (or create new list) get:

apple    banana corn     celery corn     grapes raisins  pork 

i have tried:

var listnodupes = listname.distinct(); 

and:

ienumerable<classname> listnodupes = listname.distinct(); 

but both return list in same condition before, duplicates.

you need override/implement equals() , gethashcode(), right listing distinct instances , correctly distinct/unique each other.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -