我需要对一个类型的许多实例重复调用一个给定的方法,这些实例可能存在,也可能不存在。由于方法的结果对于任何给定的实例都不会改变,所以我缓存它的返回值以供将来使用,以便减少开销并在后续调用时尽早返回,但实际执行该工作的部分仍然需要调用--可能不存在的方法--
var method = Context.Parent.GetType特定类型的Context.Parent在编译时是未知的,并且可能的运行时类型不共享具有我正在寻找的typ
如果我使用(object),那么尽管有强制转换运算符,但仍然有一个异常“类型TypeHintExcel无法转换为TypeHint”。有什么想法吗?(TypeHint和TypeHintExcel没有关系,因此我理解不能使用"as关键字“。)public static explicit operator TypeHint(TypeHintExcel p) var result = new TypeHint()
AddComponent(Menu $component) { // <-- I'm redeclaring the method only because I need to change the typehintAddObject(Menu $object, $instanceKey) { // <-- I'm redeclaring the method only because I need to change the typehintreturn parent::AddObje