Ispirer Website Ispirer Capabilities - .Net Conversion Free Trial

C# - Delegates and Events

This chapter describes delegates and events in C#.

Difference between Delegates and Events

The key difference between delegates and events is that events can be invoked only from the classes that declared them. Other classes that have access to event variables can only add subscribers, they cannot raise the events.

Even derived classes from the class declaring the event cannot fire the event directly. But you can create a method in the base class that invokes an event, and call this method from derived classes, so the event can be raised indirectly.

At the same time, delegates can be invoked by whoever has access to them.


© 1999-2024, Ispirer Systems, LLC. All Rights Reserved.