什么是IComparable的&放大器之间的差异; IEquatable接口? [英] What's the difference between IComparable & IEquatable interfaces?

查看:162
本文介绍了什么是IComparable的&放大器之间的差异; IEquatable接口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这两个接口似乎比较平等的对象,那么什么是它们之间的主要区别?

both the interfaces seem to compare objects for equality, so what's the major differences between them?

推荐答案

IEquatable 测试两个对象是否相等。

IEquatable tests whether two objects are equal.

IComparable的规定被比较的对象进行整体排序。

IComparable imposes a total ordering on the objects being compared.

例如, IEquatable 会告诉你,5不等于7. IComparable的会告诉你,5来自7之前。

For example, IEquatable would tell you that 5 is not equal to 7. IComparable would tell you that 5 comes before 7.

这篇关于什么是IComparable的&放大器之间的差异; IEquatable接口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆