Mega Code Archive

 
Categories / C# / Reflection
 

Returns the EventInfo object representing the specified event, using the specified binding constraints

using System; using System.Reflection; using System.Security; class MyEventExample {     public static void Main()     {               BindingFlags myBindingFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;             Type myTypeBindingFlags = typeof(System.Windows.Forms.Button);             EventInfo myEventBindingFlags = myTypeBindingFlags.GetEvent("Click", myBindingFlags);             if(myEventBindingFlags != null)             {                 Console.WriteLine(myEventBindingFlags.ToString());             }     } }