An
event is message or information sent by an object to signal the occurrence of an
action. Action can be anything like some logic in code being triggered or any
mouse event or third party actions. There are two things called as event sender
and event receiver. The object that raises the event is called as event sender
and the object that captures and handles the event and provides proper response
to it.
One important thing is that object sender is
not aware about the class or method being handled after the event rose. It
indicates that some references must be there to point the class or methods to
run the whole process smoothly.
To fulfill this purpose the .Net Framework provides the concepts of Delegate. It is
a class that contains the reference or pointer to a method or class and having
unique signature and even it points to only those methods that have same
signature as delegate has.
Let us see an example:
Here,
we can see the signature of both delegate and methods inside the class.
No comments:
Post a Comment