About Event Handlers, Delegates and Scopes

  • Thread starter Thread starter Alex
  • Start date Start date
A

Alex

1. Can an event handler access a private method or member of a class?
2. If so.. is that a language conceptual error?

Best regards, Alejandro Penate-Diaz.
 
It depends on your design.
If you pass a reference to the member through the event arguments - then
YES, but otherwise - NO.

Cheers,
Branimir
 
Alex said:
1. Can an event handler access a private method or member of a class?

An event handler itself is just a delegate - so really just a method.
It can do whatever any other method can do.
2. If so.. is that a language conceptual error?

I'm not really sure what you're after here. Why not try to construct
the kind of situation you think should be prohibited?
 
I' am not sure neither, but I thought that it is a dangerous situation when
somebody can add code to a class. Now I know that the compiler raises an
error in that situation, because I have tried. But take a look at
Branimir's answer.

I still think it is an interesting issue.



Alejandro.
 
Back
Top