Search for events that are declared or inherited by the current Type, using the specified binding constraints.
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);
for (int index = 0; index < myEventsBindingFlags.Length; index++)
{
Console.WriteLine(myEventsBindingFlags[index].ToString());
}
}
}
Related examples in the same category