How to convert List<T> to HashSet<T> in C#? -


this question has answer here:

i have list has duplicates of objects. solve that, need convert list hashset (in c#). know how?

make sure object's class overrides equals , gethashcode , can pass list<t> hashset<t> constructor.

var hashset = new hashset<yourtype>(yourlist); 

you may see: what best algorithm overridden system.object.gethashcode?


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -