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. 

For example:

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);
    class zzz
        //declarationof event
        public event showNameshow;
        public void tEvent()
            if(show != null)
                show("checkthe event");
    class Program
        static void Main(string[]args)
            zzzz = new zzz();
            Programp = new Program();
        public void z_show(stringstr)


check the event

  Modified On Sep-18-2014 01:23:54 PM
  1. Hi Amit Singh,

     how to understand and use the event delegate, perhaps is will english translate to my country language,Including some key technical translate not good,making it difficult to understand.    

    Now I am entrusted with the event can not be fully understood.

    thanks very much!

Leave Comment