public class CustomKey : IEquatable<CustomKey>
public string A { get; set; }
public string B { get; set; }
public bool Equals(CustomKey other)
return other.A == A && other.B == B;
public override int GetHashCode()
return string.Format("{0}{1}", A, B).GetHashCode();
public string A { get; set; }
public string B { get; set; }
public string C { get; set; }
public static void Main()
new Custom {A = "hello", B = "frog" },
new Custom {A = "jim", B = "jog" },
new Custom {A = "hello", B = "frog" },
var groups = c.GroupBy(x => new CustomKey { A = x.A, B = x.B } );
Console.WriteLine(groups.Count() == 2);