Given the following two interfaces:
public interface IFoo{}
public interface IBar
{
IFoo Foo { get; }
}
The following generic class implements the IBar interface.
public class Implementation<T> : IBar where T : IFoo
{
public T Foo { get; }
IFoo IBar.Foo => Foo;
}
Why is IFoo IBar.Foo => Foo; even necessary and is there a more elegant solution?
Of course, I could change the property Foo of the Implementation class to IFoo to get rid of the generic type. But in my application, I have other classes inheriting from the Implementation class. Those deriving classes define a specific type for the generic T : IFoo argument. For example something like:
public class Child : Implementation<FooImplementation>
{
}
public class FooImplementation : IFoo { }