<p>Several Linq.Enumerable functions take an <code>IEqualityComparer&lt;T&gt;</code>. Is there a convenient wrapper class that adapts a <code>delegate(T,T)=&gt;bool</code> to implement <code>IEqualityComparer&lt;T&gt;</code>? It's easy enough to write one (if your ignore problems with defining a correct hashcode), but I'd like to know if there is an out-of-the-box solution.</p>

<p>Specifically, I want to do set operations on <code>Dictionary</code>s, using only the Keys to define membership (while retaining the values according to different rules).</p>

I'm afraid there is no such wrapper out-of-box. However it's not hard to create one:
```
```
class Comparer<T>: IEqualityComparer<T>
{
    private readonly Func<T, T, bool> _comparer;

    public Comparer(Func<T, T, bool> comparer)
    {
        if (comparer == null)
            throw new ArgumentNullException("comparer");

        _comparer = comparer;
    }

    public bool Equals(T x, T y)
    {
        return _comparer(x, y);
    }

    public int GetHashCode(T obj)
    {
        return obj.ToString().ToLower().GetHashCode();
    }
}

...

Func<int, int, bool> f = (x, y) => x == y;
var comparer = new Comparer<int>(f);
Console.WriteLine(comparer.Equals(1, 1));
Console.WriteLine(comparer.Equals(1, 2));
```
```