98-372 · Question #119
98-372 Question #119: Real Exam Question with Answer & Explanation
The correct answer is D. EventArgs E. Object. The EventHandler delegate exposes a method that will handle an event having no event data. The event model in the .NET Framework is based on having an event delegate that connects an event with its handler. In order to raise an event, two elements are required, which are as follo
Question
Options
- AEvent
- BDelegate
- CEventHandler
- DEventArgs
- EObject
Explanation
The EventHandler delegate exposes a method that will handle an event having no event data. The event model in the .NET Framework is based on having an event delegate that connects an event with its handler. In order to raise an event, two elements are required, which are as follows: A delegate identifying the method that provides the response to the event A class containing the The delegate is a type that defines a signature, i.e., the return value type and parameter list types for a method. The delegate type can be used to declare a variable that can refer to any method with the identical signature as the delegate. The standard signature of an event handler delegate is used to define a method that does not return a value. The first parameter of the method is of type Object and refers to the instance that raises the event, and the second parameter is inherited from type EventArgs and contains the event data. If the event does not generate event data, the second parameter is just an instance of EventArgs. Otherwise, the second parameter is a custom type derived from EventArgs and provides any fields or properties required to contain EventHandler is a predefined delegate that purposely represents an event handler method for an event that does not generate data. If the event does generate data, a custom event data type must be supplied, either create a delegate where the type of the second parameter is a custom type, or employ the generic EventHandler<TEventArgs> delegate class and replace the custom type with the generic type parameter. However, in order to associate the event with the method that will handle the event, an instance of the delegate is added to the event. The event handler is invoked whenever the event takes place, unless the delegate is removed. The EventArgs class is the base class for classes that hold event data. The EventArgs class holds no event data. It is used by events that do not pass state information to an event handler whenever an event is raised. If the event handler needs state information, the application must inherit a class from the EventArgs class to hold the data. For instance, the AssemblyLoadEventArgs class holds the data for assembly load events, and holds an Assembly class that describes the loaded assembly. Answer: B is incorrect. The Delegate class is the base class for delegate types. It is not a parameter for event handler delegates. Answer: A is incorrect. The Event class is the base event for event types. It is not a parameter for event handler delegates.
Community Discussion
No community discussion yet for this question.