why the keyword 'event' is required?

  • Thread starter Thread starter Bae,Hyun-jik
  • Start date Start date
B

Bae,Hyun-jik

I am a newbie to C#.
During studying 'event' keyword, I erased the keyword 'event' and found that
its behavior doesn't change. For example:

public event AlarmEventHandler Alarm;

and

public AlarmEventHandler Alarm;

I don't know what is the difference from 'event' and no keyword.
Please reply. Thanks in advance.

Regards,
Hyun-jik Bae
 
Hi,

if you use event you are declaring an event , this event will use the
delegate AlarmEventHandler

if you do not use it you are declaring a variable of type AlarmEventHandler
, if you comes from a C background this is like a pointer to a function.

in any way they are two completely different things.


cheers,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top