I have a very simple question, but I haven't had this problem before.
Take a look at this code:
interface IFoo
{
IBar MyBar { get; }
}
interface IBar
{
String Test { get; }
}
class Foo : IFoo
{
public Bar MyBar { get; set; }
}
class Bar : IBar
{
public String Test { get; set; }
}
The problem is that Foo doesn't implement IFoo since it returns Bar rather than IBar. But I don't see the problem since Bar is implementing IBar. Do I miss something?
I want my application to use the class Foo but expose IFoo to other parts of the solution.
This is a way around it, but it seems like an ugly solution:
class Foo : IFoo
{
public Bar MyBar { get; set; }
IBar IFoo.MyBar {
get { return this.MyBar; }
}
}
Is this the way to go, or is it a better way?