How to reflect over a delegate’s signature

I’ve done some tricky work with delegates recently and I’ve had a hard time trying to reflect over the signature of a delegate type. I feel a little silly now that the solution to this has been provided to me by Eric Lippert. It’s actually quite simple, just reflect over the Invoke method:

MethodInfo invoke = typeof(Func<string, bool>).GetMethod("Invoke");
Console.WriteLine(invoke.ReturnType.Name);

I hope this helps others…

1 Comment

Comments have been disabled for this content.