[英]C# Access to implicit operators of base class
我有以下设置: Entity
来自MonoBehaviour
。 MonoBehaviour 实现了到 bool 的隐式转换。 现在,如果我在 Entity 中实现到 bool 的隐式转换,它会覆盖 MonoBehaviour 中的转换。 如果我现在想同时访问旧转换和新转换,我必须转换回基础 class
public class Entity : MonoBehaviour
{
private float CurrentHealthPoints { get; set; }
public static implicit operator bool(Entity entity)
=> (MonoBehaviour)entity && entity.CurrentHealthPoints > 0;
}
现在我的问题是,有没有一种不同的方法而不必转换到基础 class? 我尝试使用base
关键字,但无法正常工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.