Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

EventInfo.EventHandlerType Property

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

Namespace: System.Reflection
Assembly: mscorlib (in mscorlib.dll)

public Type EventHandlerType { get; }
/** @property */
public final Type get_EventHandlerType ()

public final function get EventHandlerType () : Type

Not applicable.

Property Value

A read-only Type object representing the delegate event handler.

Exception typeCondition

SecurityException

The caller does not have the required permission.

The following example uses the EventHandlerType property to discover the delegate type of an event and to display its parameter types.

The example defines a delegate named MyDelegate and an event named ev of type MyDelegate. The code in the Main method discovers the event signature by getting the delegate type of the event, getting the Invoke method of the delegate type, and then retrieving and displaying the parameters.

// The following example uses instances of classes in 
// the System.Reflection namespace to discover an event argument type.
using System;
using System.Reflection;

public delegate void MyDelegate(int i);
public class MainClass 
{
    public event MyDelegate ev;
    public void Fire(int i) 
    {
        ev += new MyDelegate(this.Fire);
    }

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

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

XNA Framework

Supported in: 1.0

Community Additions

Show:
© 2014 Microsoft