Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I get the signature of a C# delegate by its type?

Is there a straightforward way using reflection to get at the parameter list for a delegate if you have its type information?

For an example, if I declare a delegate type as follows

delegate double FooDelegate (string param, bool condition); 

and later get the type information for that delegate type as follows

Type delegateType = typeof(FooDelegate); 

Is it possible to retrieve the return type (double) and parameter list ({string, bool}) from that type info object?

like image 509
fastcall Avatar asked Jan 09 '09 20:01

fastcall


People also ask

What happens if your signature doesn't match in bank?

If you have faced a signature mismatch with your bank, just walk into the bank branch. You have to fill up some forms to submit the changed/modified signature.

Can I create my own digital signature?

You have two options for getting a digital signature: Get a digital signature from a Microsoft partner. Create your own digital signature.

How can I check my signature certificate?

Open the file that contains the certificate you want to view. Click File > Info > View Signatures. In the list, on a signature name, click the down-arrow, and then click Signature Details. In the Signature Details dialog box, click View.


1 Answers

    MethodInfo method = delegateType.GetMethod("Invoke");     Console.WriteLine(method.ReturnType.Name + " (ret)");     foreach (ParameterInfo param in method.GetParameters()) {          Console.WriteLine("{0} {1}", param.ParameterType.Name, param.Name);     } 
like image 141
Marc Gravell Avatar answered Oct 13 '22 16:10

Marc Gravell