SQLWays Product Page - Migration to .NET Free Evaluation

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.


SQLWays Product Page - Migration to .NET Free Evaluation

Discussion

Enter your comment:
OQYUG
 
sqlways/dotnet/csharp-delegates-events.txt · Last modified: April 25, 2012, 04:44:05 AM (external edit)
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki