Microsoft
98-361 · Question #380
98-361 Question #380: Real Exam Question with Answer & Explanation
The correct answer is C. handler += CalculateArea;. See the full explanation below for the reasoning.
Question
You are writing code to handle events in your program. You define a delegate named PolygonHandler like this: public delegate void PolygonHandler(Polygon p); You also create a variable of the PolygonHandler type as follows: PolygonHandler handler; Later in the program, you need to add a method named CalculateArea to the method invocation list of the handler variable. The signature of the CalculateArea method matches the signature of the PolygonHandler method. Any code that you write should not affect any existing event-handling code. Given this restriction, which of the following code lines should you write?
Options
- Ahandler = new PolygonHandler(CalculateArea);
- Bhandler = CalculateArea;
- Chandler += CalculateArea;
- Dhandler -= CalculateArea;
Community Discussion
No community discussion yet for this question.