c# - C#访问基类的隐式运算符
问题描述
我有以下设置:Entity
来自MonoBehaviour
. MonoBehaviour 实现了到 bool 的隐式转换。现在,如果我在 Entity 中实现到 bool 的隐式转换,它会覆盖 MonoBehaviour 中的转换。如果我现在想同时访问旧转换和新转换,我必须强制转换回基类
public class Entity : MonoBehaviour
{
private float CurrentHealthPoints { get; set; }
public static implicit operator bool(Entity entity)
=> (MonoBehaviour)entity && entity.CurrentHealthPoints > 0;
}
现在我的问题是,有没有一种不同的方法而不必强制转换为基类?我尝试使用base
关键字,但无法使用。
解决方案
推荐阅读
- laravel - 获取上传文件的正确 URL
- java - 检测 OutOfMemoryError - 使用 G1 时的意外行为
- sql - 从多对多关系表中选择
- r - 获取正确对象类的问题。R
- google-sheets - 如何在 Google Sheet 中使用通配符对整行使用条件格式?
- mysql - 为什么我的查询返回“OK”而不是行?
- php - 将特定类别中的 woocommerce 订单随机分配给商店经理
- javascript - 每次页面加载时如何启动功能?
- java - 从 ArrayList 中删除重复项
或者如何找出arraylist中是否已经存在类似的项目? - ffmpeg - FFMPEG - 从 MP3 到 M3u8 的音频转换适用于某些歌曲,不适用于其他歌曲。看起来像是在检测视频?