You work as the application developer at Domain.com. Domain.com uses Visual Studio.NET 2005 as its application development platform.
You are developing a Windows Forms application. You are required to create a new class that raises a large number of events and keep memory usage of the class as low as possible.
This task must be accomplished using the minimum amount of code possible.
What should you do?
A.
One instance of the EventHandlerList class should be used to store the delegate defined for each event in the class
B.
One instance of the EventInstance class should be used for each event in the class
C.
The EventBuilder class should be used to define the events for the class
D.
One member variable per event delegate should be created per event delegate instance in the class
Explanation:
The best option in this scenario would be to make use of the EventHandlerList class since the number of events is large and this method provides a memory efficient mechanism for storing a list of delegates.
Incorrect Answers:
B: This method is used for representing information for an event log entry.
C: This method is used for defining events for a dynamically generated class and in the scenario the class is not dynamically generated.
D: This method should not be used as it is not a memory efficient solution which is what is required of you.
I agree with the answer. A