Why aren't IStructuralEquatable and IStructuralComparable generic?
System.Collections.IStructuralEquatable
和System.Collections.IStructuralComparable
是在.NET 4中添加的,但它们为什么不是通用的,如IEquatable<T>
和IComparable<T>
?
The example on MSDN gives part of the answer here; it seems to be useful for heterogeneous equality, rather than homogeneous equality - ie 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.
上一篇: 网络编程:套接字功能:地址族VS协议族