C# TypeInfo GetEvents()

Description

TypeInfo GetEvents() Returns all the public events that are declared or inherited by the current Type.

Syntax

TypeInfo.GetEvents() has the following syntax.


public virtual EventInfo[] GetEvents()

Returns

TypeInfo.GetEvents() method returns

Example


using System;// w ww  . ja v a2  s.c om
using System.Reflection;
using System.Security;

class EventsSample
{
    public static void Main()
    { 
       BindingFlags myBindingFlags = BindingFlags.Instance | BindingFlags.Public;  
       Type myTypeEvent = typeof(System.Windows.Forms.Button);
       EventInfo[] myEventsBindingFlags = myTypeEvent.GetEvents(myBindingFlags);
       for (int index = 0; index < myEventsBindingFlags.Length; index++)
       {
           Console.WriteLine(myEventsBindingFlags[index].ToString());
       }
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Reflection »




EventInfo
FieldInfo
MemberInfo
MethodInfo
ParameterInfo
TypeInfo