11
votes

I've read this post but it doesn't answer my question.

MSDN says:

We recommend that you derive from the EqualityComparer(Of T) class instead of implementing the IEqualityComparer(Of T) interface, because the EqualityComparer(Of T) class tests for equality using the IEquatable(Of T).Equals method instead of the Object.Equals method.

but if I look at the implementation, they both use the generic Type:

 public class AAA:IEqualityComparer<Box>
    {
        public bool Equals(Box x, Box y)
        {
        }

        public int GetHashCode(Box obj)
        {
        }
    }

    public class BBB : EqualityComparer<Box>
    {
        public override bool Equals(Box x, Box y)
        {
        }

        public override int GetHashCode(Box obj)
        {
        }
    }

What am I missing?

1
No idea. That statement makes no sense to me. - CodesInChaos
The answers to the other question already explained that this statement makes no sense. So I don't get what you're expecting out of this question. - CodesInChaos
@CodeInChaos did you read the answers there? none of them was a strict answer ... The accepted answer gave explanation about the Compare interface and assumed it might be relevant to Equality....jOn skeet didnt know about his first question either. so your duplicate vote is from not-reading.\ - Royi Namir
I read those answers as "the statement is bullshit and makes no sense", except they're too polite to say it in such an explicit way. While MSDN is a valuable resource, don't take everything MSDN says as gospel. MSDN contains plenty of bad advice, outdated, badly written or plain wrong content. - CodesInChaos

1 Answers

4
votes

I think the other post you mention is saying that EqualityComparer<Box> implements IEqualityComparer<Box> and IEqualityComparer, so you don't have to implement both the generic and non-generic interfaces if you derive from EqualityComparer<Box>.