为什么不IStructuralEquatable和IStructuralComparable通用? [英] Why aren't IStructuralEquatable and IStructuralComparable generic?

查看:237
本文介绍了为什么不IStructuralEquatable和IStructuralComparable通用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

System.Collections.IStructuralEquatable System.Collections.IStructuralComparable 添加在.NET 4中,但为什么AREN 'T他们通用的,如 IEquatable< T> IComparable的< T>

System.Collections.IStructuralEquatable and System.Collections.IStructuralComparable were added in .NET 4, but why aren't they generic, like IEquatable<T> and IComparable<T>?

推荐答案

的的例如在MSDN上这里给出了部分答案;这似乎是异质的平等,而不是均匀相等有用的 - 即用于测试是否的可能不同的类型的应该被视为相等的两个对象(/值)。在这样的情况下,这是非常有可能调用code是处理对象(重新present异构数据)。而通用的方法不玩了很好的话。

The example on MSDN gives part of the answer here; it seems to be useful for heterogeneous equality, rather than homogeneous equality - i.e. for testing whether two objects (/values) of potentially different types should be considered equal. In such scenarios, it is extremely likely that the calling code is dealing with object (to represent heterogeneous data). And generic methods don't play nicely then.

这篇关于为什么不IStructuralEquatable和IStructuralComparable通用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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