本文介绍了IEqualityComparer与EqualityComparer?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经阅读了此帖子,但它没有回答我的问题.
I've read this post but it doesn't answer my question.
MSDN 说法:
但是,如果我看一下实现,它们都使用通用类型:
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)
{
}
}
我想念什么?
推荐答案
我认为其他帖子您提到的是说 EqualityComparer< Box>
实现了 IEqualityComparer< Box>
和 IEqualityComparer
,因此您不必同时实现通用和非通用接口,如果您从 EqualityComparer< Box>
派生.
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>
.
这篇关于IEqualityComparer与EqualityComparer?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!