O'Reilly logo

Applied Microsoft® .NET Framework Programming by Jeffrey Richter

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 a Type That Defines Lots of Events

In the previous section, I described a scenario in which you might want to explicitly provide add and remove accessor methods for an event. However, when you’re explicitly implementing the accessor methods yourself, you can get a bit more creative with their implementation. Let’s see how explicitly implementing these methods can reduce the memory usage of an application.

The System.Windows.Forms.Control type defines about 60 events. If the Control type implemented the events by allowing the compiler to implicitly generate the add and remove accessor methods and delegate fields, then every Control object would have 60 delegate fields in it just for the events! Because objects never register interest in ...

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