[英]Why can't I get Type.GetType() to find the type of my plugin instance referenced in app.config?
[英]Why can't I get the MethodBody of GetType()?
假设我有这行:
MethodBody getTypeMethod = typeof(object).GetMethod("GetType").GetMethodBody();
// getTypeMethod is null
为什么getTypeMethod
null? 如何获取GetType()
方法的MethodBody
?
您可以自己回答,但是只是为了确认一下, Object.GetType()
是一个外部方法,而外部方法没有指定方法主体。
从C#规范10.6.7
当方法声明包含extern修饰符时,该方法被称为外部方法。 外部方法通常是使用C#以外的语言在外部实现的。 由于外部方法声明不提供任何实际实现,因此外部方法的方法主体仅由分号组成。
这是更详尽的答案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.