O'Reilly logo

C# 5.0 Unleashed by Bart De Smet

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Designing Events for Use by Derived Classes

What about extenders of our CountDown type? Assume we’ve designed our countdown mechanism such that its core functionality can be overridden (for example, by marking Start as virtual) or we simply haven’t sealed the class. The subtype might want to raise any of our events as part of its extension. For example, a CountDown with an EmergencyStop facility might want to call Finished before the timer reaches zero. I invite you to think about more examples.

The key question is whether a subtype can raise an event declared on its base type. A little bit of reasoning can help answer this question without having to loop in the compiler just yet. You’ve seen how an event declaration leads to the creation of ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required