Events question for school

VBNetStudent

New member
Joined
Jan 7, 2013
Messages
2
Programming Experience
Beginner
Hello All,

I am currently taking a Net Programming course. I had a question on one of my quiz problems and am hoping someone can clear this up for me.

I was doing the quiz on Events and after submitting I noticed that I got the first question wrong, which asks: "Syntax for declaring an Event is ____", to which I chose the answer "Public Event evtSample", however the correct answer is apparently "Public Event evtSample as sampleDel". My only problem is that in the section in which we learn about events, the code shows that my answer is used to declare an event, and in the assignment that follows I also used that same syntax and the event worked fine. I'm just confused on how the answer could be something that we weren't taught to use as the syntax for it.

Any help is appreciated. Thank you!
 
"Public Event evtSample" is correct, though 'pretty formatting' IDE option will write that as "Public Event evtSample()" where the paranthesis means an empty parameter list, just like it does for method definitions and calls.
"Public Event evtSample as sampleDel" could be correct also if a delegate type 'sampleDel' is defined.
With the first declaration compiler automatically generates an appropriate delegate and changes the compiled code for the event to reflect that, but that's a technicality that VB programmers rarely dive into.
It is certainly very useful to learn however, how events are composed, and it is not uncommon to declare events with their delegate type.
 
Back
Top