[英]how to get return value from a method of custom type using reflection?
我在类中有一个返回自定义类型的方法。 我正在使用反射来调用此方法,但无法获得响应。
注意:我无法将返回值转换为自定义类型,因为我无法在项目中引用dll。
Response = method.Invoke(instance, new[] { parameter});
Response
为空。 此方法调用应返回自定义类型。
您将获得响应作为System.Object
:
object response = method.Invoke(instance, new[] { parameter });
有多种原因,你仍然可以得到null
的响应,包括该方法本身返回null
或者它是一个void
的方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.