Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why aren't IStructuralEquatable and IStructuralComparable generic?

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

like image 880
thecoop Avatar asked Feb 11 '11 11:02

thecoop


1 Answers

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.

like image 88
Marc Gravell Avatar answered Nov 15 '22 05:11

Marc Gravell