When to use IEqualityComparer in a .NET 4.0 Targeted Application

Is there any benefit to me implementing weakly typed IEqualityComparer in .NET 4.0 applications in addition to the IEqualityComparer<T> interface?

In another angle, I can always implement IEqualityComparer<System.Object> to create an equally weakly typed script and never resort to IEqualityComparer for new code.

+4
source share
1 answer

If you just exit EqualityComparer<T> , you have nothing to worry about, because it implements both IEqualityComparer and IEqualityComparer<T> . Thus, you get weak typing for free when you implement strong typing.

However, it is unlikely that you will need a weakly typed version. Only a few BCL classes use it, and they are not common.

+4
source

Source: https://habr.com/ru/post/1335705/


All Articles