IComparable的和IComparable的< T> [英] IComparable and IComparable<T>

查看:169
本文介绍了IComparable的和IComparable的< T>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我应该同时实施 IComparable的和通用 IComparable的< T> ?是否有任何限制,如果我只能实现其中之一吗?

Should I implement both IComparable and the generic IComparable<T>? Are there any limitations if I only implement one of them?

推荐答案

是的,你应该同时实现。

Yes, you should implement both.

如果您实现一个,那要看对方会失败的任何代码。

If you implement one, any code that depends on the other will fail.

有大量的代码,使用或者 IComparable的 IComparable的< T> 而不是两个,因此同时实现确保你的代码将与这样的代码工作。

There is lots of code that uses either IComparable or IComparable<T> but not both, so implementing both ensure your code will work with such code.

这篇关于IComparable的和IComparable的&LT; T&GT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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