98-372 · Question #111
Which element is NOT required if you need a custom class to raise an event?
The correct answer is A. A method to add an event handler. You do not need a method to add an event handler because that functionality is provided by the .NET Framework. An event handler is a course of action in program code and it is performed when an event occurs. Therefore, when an event is raised, the code within the event handler…
Question
Which element is NOT required if you need a custom class to raise an event?
Options
- AA method to add an event handler
- BA class containing event data, derived from EventArgs
- CA delegate for the event
- DA class raising the event
How the community answered
(33 responses)- A79% (26)
- B12% (4)
- C6% (2)
- D3% (1)
Explanation
You do not need a method to add an event handler because that functionality is provided by the .NET Framework. An event handler is a course of action in program code and it is performed when an event occurs. Therefore, when an event is raised, the code within the event handler is executed. In order to handle an event, the event handler provides two parameters. The first parameter passes a to the event that is being handled by the event handler. Event handlers can be created using the Windows Forms Designer as well as during runtime. Answer: C, D, and B are incorrect. If you are required to raise an event in a custom class, you need a class that contains the event data, either EventArgs or a class inheriting from EventArgs, a delegate for the event, and a class raising the event.
Topics
Community Discussion
No community discussion yet for this question.