Skip to content

Instantly share code, notes, and snippets.

@sophie-eihpos
Created November 14, 2012 17:06
Show Gist options
  • Save sophie-eihpos/4073364 to your computer and use it in GitHub Desktop.
Save sophie-eihpos/4073364 to your computer and use it in GitHub Desktop.
class Comparer<T>
class Comparer<T> : IEqualityComparer<T>
{
public 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.GetHashCode();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment