I have an inheritance tree, which looks like this:
Foo and Bar both have an Id, as defined through an specific Id class.
The id classes itself are derived from a common base class.
I would now like to write an interface which can encompass both Foo and Bar,
but the compiler does not allow that, I would have to use BaseId as the type in Foo and Bar, but I would like to avoid that.
public class BaseId
{
public string Id {get; set;}
}
public class FooId: BaseId
{}
public class BarId: BaseId
{}
public interface MyInterface
{
public BaseId Id {get; set; }
}
public class Foo: MyInterface
{
public FooId Id {get; set;}
}
public class Bar: MyInterface
{
public BarId Id {get; set;}
}