■
Note
Strictly speaking, we could have defined our delegate member variables as public, therefore avoiding the
need to create additional registration methods. However, by defining the members as private, we are enforcing
encapsulation services and providing a more type-safe solution. You’ll revisit the risk of public delegate member
variables later in this chapter when examining the C#
event
keyword.
At this point, we need to update the Accelerate() method to invoke each delegate, rather than
iterate over an ArrayList of client-side sinks (as we did in the CallbackInterface example). Here is
the update:
public void Accelerate(int delta)
{
Do'stlaringiz bilan baham: |