Several Linq.Enumerable functions take an IEqualityComparer<T>. Is there a convenient wrapper class that adapts a delegate(T,T)=>bool to implement IEqualityComparer<T>? 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.
Specifically, I want to do set operations on Dictionarys, using only the Keys to define membership (while retaining the values according to different rules).
Ordinarily, I’d get this resolved by commenting @Sam on the answer (I’ve done some editing on the original post to clean it up a bit without altering the behavior.)
The following is my riff of @Sam’s answer, with a [IMNSHO] critical fix to the default hashing policy:-