using System; using System.Linq; public static class Equality { public static bool Test(T a, T b, Func compare) { if (Object.ReferenceEquals(a, null)) { return Object.ReferenceEquals(b, null); } else { return compare(a, b); } } public static bool Field(T a, T b, Func getField, Func compareField) { if (Object.ReferenceEquals(a, null)) { return Object.ReferenceEquals(b, null); } else { return compareField(getField(a), getField(b)); } } }