例えば:
public interface IFoo
{
//...
ICollection<IFoo> Children { get; }
//...
}
public class Foo : IFoo
{
//...
public ICollection<Foo> Children { get; private set; }
//...
public ICollection<IFoo> IFoo.Children
{
get
{
return Children; // Obviously wrong datatype, how do I cast this?
}
}
//...
}
では、どうすれば正しく実装できIFoo.Children
ますか? 私は試しChildren.Cast<IFoo>
ましたが、これは代わりにを返しますIEnumerable<IFoo>
。