Hi there,
I have the following class hierarchy that isn't compiling correctly, and I
don't understand why:
public abstract class A<Twhere T : System.IComparable<T{ }
public abstract class B : System.IComparable<B>
{
public abstract int CompareTo(B other);
}
public abstract class C<T: A<Twhere T : B {}
The compiler (Visual Studio 2005) reports that class C has the following
error:
The type 'T' must be convertible to 'System.IComparable<T>' in order to use
it as parameter 'T' in the generic type or method 'A<T>'
I'm confused by this, because in class C, I'm constraining type T to be of
type class B, and class B is IComparable<B>. So, shouldn't class C's type T
therefore be IComparable<B>? Could someone explain why this is an error?
Thanks in advance!
--
Whitney Kew
Senior Software Engineer