Search code examples
c#.netreflectionpostsharp

How do I find the return type of a method with System.Reflection.MethodBase in C#?


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.

Thanks,


Solution

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

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