I want to declare a class that inherits a generic class and implements an interface, such as the following:
public class SortableObject
{
int compare(SortableObejct obj);
}
public class List<T> where T is class
{
public void add(T obj);
public T peekCurrent();
}
public class SortedList<T> : List<T> where T : SortableObject, SortableObject
{
public override int compare(SortableObejct obj);
}
I want SortedList<T>
inherits from List<T>
and implements from SortableObject
, where T
is a subclass from SortableObject
. The c# compiler fails to compile such class; it seems to me that the grammar does not support this case.
Would anyone have met such difficulty and have a solution for it ?