Implementing the IEqualityComparer of T interface for object equality with C# .NET
October 20, 2017 Leave a comment
The generic IEqualityComparer of T provides you a way to indicate whether two custom objects are equal. We’ve looked at equality in a number of posts on this blog – see the link below if you’re curious – and IEqualityComparer fulfils a similar purpose though its usage is different.
Equality comparers are most often used to filter out duplicates from a collection.
Consider the following class: