constrained generic base class AND implementing an interface

P

ProjectNut

what is the syntax for implementing an interface in a generic class
that has a constrained base class

example:

class myclass<T>: mybase<T> where T: IComparable
{
}

Now, I want myclass<T> to implement IMyInterface. What is the syntax
for this?

class myclass<T>:mybase<T> where T:IComparable, IMyInterface - doesnt
work because this says that the class 'mybase<T>' has an additional
constraint on T

class myclass<T>:IMyInterface, mybase<T> where T:IComparable - doesnt
work because base classes must come before any interfaces that are
implemented.

So how do I tell the compiler that I want myclass<T> to implement the
interface IMyInterface when it is a sub class of mybase<T> where T is
constained?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top