Returns all the public events that are declared or inherited by the current Type. : Event « Reflection « C# / C Sharp






Returns all the public events that are declared or inherited by the current Type.

 

using System;
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);
            Console.WriteLine("\nThe events on the Button class with the specified BindingFlags are : ");
            for (int index = 0; index < myEventsBindingFlags.Length; index++)
            {
                Console.WriteLine(myEventsBindingFlags[index].ToString());
            }
    }
}

   
  








Related examples in the same category

1.Show Events
2.EventInfo Class discovers the attributes of an event and provides access to event metadata.
3.Use reflection to get the Elapsed event
4.Get event handler type
5.EventInfo.EventHandlerType
6.Returns the EventInfo object representing the specified public event.
7.Returns the EventInfo object representing the specified event, using the specified binding constraints.
8.Search for events that are declared or inherited by the current Type, using the specified binding constraints.