Define Delegates.A delegate acts like a strongly type function pointer. Delegates can invoke the methods that they reference without making explicit calls to those methods. It is type safe since it holds reference of only those methods that match its signature. Unlike other classes, the delegate class has a signature. Delegates are used to implement event programming model in .NET application. Delegates enable the methods that listen for an event, to be abstract.Define Events.Events are one of the members of the class. When any noteworthy activity occurs in the application, an event is raised which sends out the message to the other part of the application which handles the event. The event can carry arguments that contain information about the event. The method which handles the event must have the same signature as the event itself. Events are commonly used in the applications with graphical user interface elements such as buttons, textbox etc. An event is triggered when any action such as mouse click occurred in the interface element. The event-based programming model can be used in the non-GUI applications such as .NET Remoting application. An event in remoting.net occurs when the state of the application changes.
|