I have a Generic Interface
public interface TheInterface<T> where T : IObject
I also have an object class that this interface works with
public class SomeObject : IObject
I then have a class that implements the interface
public class ClassThatWorksWithSomeObject : TheInterface<SomeObject>
This all works well enough. Later on I add a class that works with TheInterface class independent of what version of IObject he uses.
public class IDoStuffToInterface
{
public IDoStuffToInterface(TheInterface<IObject> interface)
{
//bla bla
}
}
Problem is I can’t pass ClassThatWorksWithSomeObject in there, even if It inherits from the intreface and it’s generic object inherits from IObject.
I guess there are some cases that it could be hurtful if it did, but I can’t think of any.
Is there a way to do this better?
I don’t know the detail impelmentation, you can try:
if you are using C#4.0