NEWBIE: Where does a delegated method "occur"?
Posted on 2007-07-24
I'm a C# newbie trying to understand events. Please take this example:
I have a Clock class, which declares an event. I have a DisplayTime class, which registers a method with the Clock class event. (Lifted from O'Reilly's Programming C#, thank you.)
When that method executes, is it correct to think of it as the Clock class calling a method inside of the DisplayTime class? Or is it better to think of it as the Clock method itself executing a chunk of code that happened to come from the DisplayTime class originally?
Specifically, can the method refer to instance and class variables inside of the original DisplayTime class, which are not defined in the method itself?
Yours in Slowly-Subsiding Confusion,