C# EventInfo EventHandlerType

Description

EventInfo EventHandlerType Gets the Type object of the underlying event-handler delegate associated with this event.

Syntax

EventInfo.EventHandlerType has the following syntax.


public virtual Type EventHandlerType { get; }

Example

The example defines a delegate named MyDelegate and an event named ev of type MyDelegate.


/*from   w  w  w .  ja va  2 s .  co  m*/

using System;
using System.Reflection;

public delegate void MyDelegate(int i);
public class MainClass 
{
    public event MyDelegate ev;

    public static void Main() 
    {
        Type delegateType = typeof(MainClass).GetEvent("ev").EventHandlerType;
        MethodInfo invoke = delegateType.GetMethod("Invoke");
        ParameterInfo[] pars = invoke.GetParameters();
        foreach (ParameterInfo p in pars) 
        {
            Console.WriteLine(p.ParameterType);
        }
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Reflection »




EventInfo
FieldInfo
MemberInfo
MethodInfo
ParameterInfo
TypeInfo