Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
internal sealed class DynamicEqualityComparer<T> : IEqualityComparer<T>
where T : class
{
private readonly Func<T, T, bool> _func;
public DynamicEqualityComparer(Func<T, T, bool> func)
{
DebugCheck.NotNull(func);
_func = func;
}
public bool Equals(T x, T y)
{
return _func(x, y);
}
public int GetHashCode(T obj)
{
return 0; // force Equals
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment