Ann L.
Ann L.

Reputation: 13975

Is there a .NET EqualityComparer-based class that works with two collections of the same type of object?

Is there an EqualityComparer-based or -style class in .NET that works on collections?

I am considering the case of comparing two objects for property-value-based value equality. When the property is a collection, I am contemplating methods to compare the objects in the collection for value equality.

The simplest thing would be to pair up the items from the two collections, and perform equality comparisons on the pairs of items until one comparison returns false, or you run out of items in one or both collections (if you didn't/can't determine item count up front.)

But I wondered whether there was already a class that did this.

I have looked via Object Browser in Visual Studio at everything I could find with "EqualityComparer" in its name, but that isn't necessarily exhaustive. It also doesn't list everything implementing a given interface or descending from a given class. (I wish Reflector were still free!)

(Note: by "collection" I mean "anything that implements IEnumerable or can be converted to one.")

Upvotes: 0

Views: 38

Answers (0)

Related Questions