Interface referencing another interface but class referencing another class in C#
<p>I have a very simple question, but I haven't had this problem before.</p>

<p>Take a look at this code:</p>

<pre><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; }
}
</code></pre>

<p>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?</p>

<p>I want my application to use the class Foo but expose IFoo to other parts of the solution.</p>

<p>This is a way around it, but it seems like an ugly solution:</p>

<pre><code>class Foo : IFoo
{
    public Bar MyBar { get; set; }
    IBar IFoo.MyBar { 
        get { return this.MyBar; }
    }
}
</code></pre>

<p>Is this the way to go, or is it a better way?</p>
