C# TypeInfo GetEvent(String)
Description
TypeInfo GetEvent(String)
Returns the EventInfo object
representing the specified public event.
Syntax
TypeInfo.GetEvent(String)
has the following syntax.
public EventInfo GetEvent(
string name
)
Parameters
TypeInfo.GetEvent(String)
has the following parameters.
name
- The string containing the name of an event that is declared or inherited by the current Type.
Returns
TypeInfo.GetEvent(String)
method returns The object representing the specified public event that is declared or inherited
by the current Type, if found; otherwise, null.
Example
using System;/* w ww .j ava 2 s . co m*/
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.