Difference between Method and Event

Hi,
I read about Object-oriented programming but I confused a little bit.

I can define own Event Handlers to my classes.
It can be called only from the class itself.
They can be implemented only by its subclasses.
When I implement an event handler, it no longer appears in subclasses.

By contrast the Method:
can call in the class and its subclass,
can be override.

I infer correctly the calling a method start a search upwards towards ancestors?
By contrast the Event Handler search downwards offspring?

A common technique when you handle an event in one class is to also define a new event in the class (with the same name) and then raise it, so the event can keep propagating to offspring.

[quote=231854:@Zsolt Szokolai]I infer correctly the calling a method start a search upwards towards ancestors?
By contrast the Event Handler search downwards offspring?[/quote]

That’s right. It’s an effective way for your superclass to communicate with the subclasses, and you can determine order.

For example, suppose you implement the Open event then, as described by Michael, define a new Open event for the subclass. You can RaiseEvent Open() in the super at a time you define, or not at all depending on conditions.

Thank you!

I think of it as a message than function call?
Hello, there is someone out there who wants to do that?
And the solving stuff being looking for a superclass (in case method) or a subclass (in case event) who can do it.
My approach correct?

It’s more about order and control. When you call an override method, the subclass gets it first and can decide when, or if, the superclass method should be called. When you implement an event, the superclass gets it first and can decide when, and if, to raise the event in the subclass.

Keep in mind that events can’t be raised from outside the class, another consideration.

Events also cannot be targets of AddHandler nor can they satisfy Interfaces.

AddHandler delegates the handling of the event to the method named in the addressof call
You can’t use addHandler to delegate the call to one method to another

Events do traverse “down” the hierarchy as long as you continue to add event definitions & raise them

Methods go “up” the hierarchy as long as you call the supers method from the subclass

Events make implementing “chain of responsibility” very simple

Thank you Norman!
This will be a good start reading…