Get EventInfo object representing the specified public event in CSharp
Description
The following code shows how to get EventInfo object representing the specified public event.
Example
using System;//from w w w. j ava2 s . com
using System.Reflection;
using System.Security;
class MyEventExample
{
public static void Main()
{
Type myType = typeof(System.Windows.Forms.Button);
EventInfo myEvent = myType.GetEvent("Click");
if(myEvent != null)
{
Console.WriteLine("Looking for the Click event in the Button class.");
Console.WriteLine(myEvent.ToString());
}
}
}
The code above generates the following result.