What do you mean by 'event' modifier in C# programming language?

 Posted by Goud.Kv on 9/3/2014 | Category: C# Interview questions | Views: 1833 | Points: 40
Answer:

event modifier is used to declare any events by using handlers. This modifier is generally used in notification systems where we need to have number of event types.
Any changes and other implementations can be done without disturbing the remaining code of the application.

Example,
public static event EvtHandler MyEvent; // EvtHandler must have been specified outside by using 'delegate' keyword. 


static void Main()
{
MyEvent = new EvtHandler(MeetFriends); //Adding notification to the event
MyEvent.Invoke(); //Invoking the event
}

static void MeetFriends()
{
..........;
.........;
}


Asked In: Spotted While Learning | Alert Moderator 

Comments or Responses

Login to post response