System.Collections.IStructuralEquatable
and System.Collections.IStructuralComparable
were added in .NET 4, but why aren't they generic, like IEquatable<T>
and IComparable<T>
?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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.