From the comments, it sounds like you have a bunch of structured data, with subobjects of various types.
If the collections are large, the fastest way would be to use a dynamic codegen (possibly with expression trees) to create a single method that pulls out all the fields / properties of interest in a strongly typed way and performs strongly typed comparisons.
Basically, you use reflection to dynamically retrieve field / property types from a collection item type. Then you create MemberAccessExpression expressions, pass them to Expression.Equal , and all the results to Expression.AndAlso . Compiling the expression gives you a delegate that accepts two objects of a certain type contained in the collection.
The launch time will be a couple of orders slower than the code that you indicated in your question, but the cost per object will be much lower. You will need to check where the breakeven point is, but probably at low thousands.
source share