Hi,
When you declare a delegate a class is automatically generated for you
behind the scenes. This class has an Invoke method which takes the same
parameters as the declared delegate. This means that the following code will
print out the parameter-types for your GetObject delegate (which - by the way
- has the exact same signature as the delegate System.EventHandler provided
by the framework):
Type t = typeof(GetObject);
MemberInfo[] invoke = t.GetMember("Invoke");
ParameterInfo[] parameters = ((MethodInfo) invoke[0]).GetParameters();
foreach (ParameterInfo p in parameters)
Console.WriteLine(p.ParameterType.ToString());
HTH, Jakob.
[quoted text, click to view] "Viorel Ghilas" wrote:
> Hi all,
>
> I have a delegate like this public delegate void GetObject(Object source,
> EventArgs e);
> how can I take the parammeter types in runtime from this type, using
> reflection. The problem is that I have this delegate, attribute class that
> must be applied on the methods with delegate structure. Before invoke the
> method I need to check if method correspond to delegate type. How to do it,
> I am opening for any sugestions, pls.
>
> with best regards
> Viorel Ghilas
>
>