An event is delivered to an object by means of a call to amethod in that object. An event isdelegate type class member that is used by the object or class and it provide anotification to other objects that an event has occurred.
We define the event as
modifiers event type NameOfEvent
Where modifiersmay be access modifiers like public, protected, private etc.
event is keywordwhich shows the name of event.
type shows theevent declaration which is the name of delegate.
And NameOfEventis a variable.
Public event showEventshow;
Where showEventis delegates and show is event.
Note: Event isthe part of delegate so first we define the delegate for that event and theninstance of delegate by using keyword event.
How use an event handler
In this example how we implement the event handler
//declaration thedelegate here
public delegate void showName (stringstr);
public event showNameshow;
public void tEvent()
if(show != null)
static void Main(stringargs)
zzzz = new zzz();
Programp = new Program();
public void z_show(stringstr)
check the event