문제

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

Another angle is I can always implement IEqualityComparer<System.Object> to make up an equally weakly typed scenario and never need to resort to IEqualityComparer for new code.

도움이 되었습니까?

해결책

If you just derive from EqualityComparer<T> then you don't have to worry about it because it implements both IEqualityComparer and IEqualityComparer<T>. So you get weak typing for free when you implement strong typing.

That said, it's reasonably unlikely that you'll find yourself needing the weakly-typed version. Only a handful of BCL classes use it, and they're not common ones.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top