title: Performance of HashSet<T> and Linq queries
body: <p>During last week I received some code and was asked to improve the performance. So started with the job, but soon I saw that they use a lot of <code>HashSet&lt;T&gt;</code> objects, to store big collections of objects (between 10000 to more than 100000 objects). In the code they use <code>HashSet&lt;T&gt;</code> for performance reasons.</p>
  
  <p>The only thing that they do is populate the HashSet with objects and then us some Linq to execute queries between multiple collections. Most of the queries are joining 1 or n HashSet, or retrieving specific object(s) from the collection with <code>First()</code> or <code>Where()</code>.</p>
  
  <p>I'm wondering if we gain any performance advantage compared to a normal <code>List&lt;T&gt;</code>?  Because all the Linq extension methods they use in code are written for <code>IEnumerable&lt;T&gt;</code>.</p>
  
  <p>On the internet a lot of articles say that List would be faster, but some say that HashSet handles huge collections much better than List.</p>
  
  <p>Hope that someone can give me more advice.</p>
  
  <p>Thanks.</p>