473,326 Members | 2,127 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

About Event Handlers, Delegates and Scopes

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.
Nov 16 '05 #1
3 944
It depends on your design.
If you pass a reference to the member through the event arguments - then
YES, but otherwise - NO.

Cheers,
Branimir

--
Branimir Giurov
MCSD.NET, MCDBA
"Alex" <al********@hotmail.com> wrote in message
news:Ob***************@TK2MSFTNGP11.phx.gbl...
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.

Nov 16 '05 #2
Alex <al********@hotmail.com> wrote:
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?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #3
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.
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Alex <al********@hotmail.com> wrote:
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?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Ian Richardson | last post by:
I'm writing some code which does one thing when onreadystatechange occurs, e.g. handle.onreadystatechange = function() { blah(handle,other_params) }; ....but sometimes I need to add another,...
1
by: MuZZy | last post by:
Hi, Is there a way to remove all event handlers for a control's event? Say, i have a button and i want to remove all button.Click events for it - i don't know how many of them was hooked to the...
3
by: Minh Khoa | last post by:
Please give me more information about delegate and its usage? Why do i use it and when?
31
by: Scott M. | last post by:
Am I correct in thinking that because C# doesn't have the "Handles" keyword that VB .NET does, we have to register event delegates manually in C#, whereas in VB .NET using "Handles" takes care of...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.