troubleshooting Question

NEWBIE: Where does a delegated method "occur"?

Avatar of BrianMc1958
BrianMc1958 asked on
6 Comments3 Solutions245 ViewsLast Modified:
Dear Experts,

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,
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 3 Answers and 6 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 3 Answers and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros