C# 方法信息 getReturnType

标签 c# .net reflection void methodinfo

我创建了一个 MethodInfo 实例:

MethodInfo theMethod = typeof(Reciever).GetMethod("methodName", parameterTypes);

现在我想知道方法的返回类型是否为空。怎么办?

最佳答案

简单:

theMethod.ReturnType == typeof(void)

关于C# 方法信息 getReturnType,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1013443/

相关文章:

c# - .net framework 上的 startup 和 startup.auth 代码放在哪里(不是 .net core)

c# - 定期发送自动电子邮件

c# - 为什么 IsDebugEnabled 在我的代码中总是 True?

c# - 单例实现在 32 位但不是 64 位上工作正常

C#继承问题

c# - 当 typeName 表示大小无效的数组类型时,Type.GetType() 抛出

c# - 调用动态方法时"Operation could destabilize the runtime"

c# - "MouseLeftButtonDown"TreeViewItem 中未引发事件,为什么?

c# - 合并两个列表和一个字典以创建一个字典

c# - 通过反射在 C# 中获取委托(delegate)集合的所有具体实现