title: HashSet constructor with custom IEqualityCompare defined by lambda?
body: <p>Currently the <code>HashSet&lt;T&gt;</code> constructor that allows you to define your equality comparison yourself is the <code>HashSet&lt;T&gt;(IEqualityComparer&lt;T&gt; comparer)</code> constructor.
  I would like to define this EqualityComparer as a lambda.  </p>
  
  <p>I found <a href="http://brendan.enrick.com/blog/linq-your-collections-with-iequalitycomparer-and-lambda-expressions/" rel="noreferrer">this blog post</a> that has made a class that allows you to generate your comparer through lambda and then hides the construction of this class with an extention method to do for example an Except().  </p>
  
  <p>Now I would like to do the same but with a constructor. Is it possible to create a constructor through an extention method? Or is there another way I could somehow create a <code>HashSet&lt;T&gt;(Func&lt;T,T,int&gt; comparer)</code>?</p>
  
  <p><strong>--UPDATE--</strong><br>
  For clarity, this is (a snippet of) a freehand version of what I'm trying to accomplish:</p>
  
  <pre><code>HashSet&lt;FileInfo&gt; resultFiles = new HashSet&lt;FileInfo&gt;(
      srcPath.GetFiles(),
      new LambdaComparer&lt;FileInfo&gt;(
          (f1, f2) =&gt; f1.Name.SubString(10).Equals(f2.Name.SubString(10))));
  </code></pre>
  
  <p>or more ideally</p>
  
  <pre><code>HashSet&lt;FileInfo&gt; resultFiles = new HashSet&lt;FileInfo&gt;(
      srcPath.GetFiles(),
      (f1, f2) =&gt; f1.Name.SubString(10).Equals(f2.Name.SubString(10)));
  </code></pre>