public interface IUpgradeable
{
IUpgrade UpgradeEntity{ get; }
}
public interface ISomeUpgrade : IUpgrade
{
// ...
}
public interface IUpgrade
{
// ...
}
public class SomeClass : IUpgradeable
{
public ISomeUpgrade SomeUpgrade { // ...}
}
`
为什么我不能用它?我需要更多接口来实现IUpgrade ......
答案 0 :(得分:0)
SomeClass
未实施IUpgradeable.UpgradeEntity.get
您指定了具有不同名称和不同返回类型的属性...
你能做的是
public class SomeClass : IUpgradeable
{
public IUpgrade UpgradeEntity { get { ... return new CSomeUpgrade(); } }
}
答案 1 :(得分:0)
您必须明确地实现UpgradeEntity:
public interface IUpgradeable
{
IUpgrade UpgradeEntity { get; }
}
public interface ISomeUpgrade : IUpgrade
{
// ...
}
public interface IUpgrade
{
// ...
}
public class SomeClass : IUpgradeable
{
IUpgrade IUpgradeable.UpgradeEntity => SomeUpgrade;
public ISomeUpgrade SomeUpgrade { get; }
}
答案 2 :(得分:0)
您的类必须严格实现接口,不能更改返回类型的属性名称。
如果我理解正确,你真正想要的是一个实现btn.setOnAction(e -> window.setScene(anotherScene));
的类,每个类有IUpgradable
个不同的类。这可以使用泛型来获得:
IUpgrade