如何在C#中使用System.Reflection.MethodBase查找方法的返回类型? [英] How do I find the return type of a method with System.Reflection.MethodBase in C#?

查看:48
本文介绍了如何在C#中使用System.Reflection.MethodBase查找方法的返回类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从MethodBase中找出方法的返回类型?我正在使用PostSharp并尝试覆盖CompileTimeValidate(MethodBase方法)方法,以确保将该属性应用于具有正确签名的方法.

how do I find out the return type of a method from the MethodBase? I'm using PostSharp and trying to override the CompileTimeValidate(MethodBase method) method to make sure the attribute is applied to a method with the correct signature.

谢谢

推荐答案

MethodBase用作返回类型.

MethodBase is used as a base class of MethodInfo which has a property ReturnType.

您可以尝试将其强制转换为MethodInfo的实例并检查该属性.

You could try and cast to an instance of MethodInfo and check that property.

这篇关于如何在C#中使用System.Reflection.MethodBase查找方法的返回类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆