Accessor declarations for events in VB.Net

G

Guest

Hi all,

I'm attempting to port some C# code over to VB.Net. It was going well until
I hit the following code:

public virtual event PInputEventHandler KeyDown {
add { handlers.AddHandler(keyDownEventKey, value); }
remove { handlers.RemoveHandler(keyDownEventKey, value); }
}

It appears that one can declare Add and Remove accessors within an event
declaration in C#. Is there any way to do this in VB.Net?

Thanks.
 
H

Herfried K. Wagner [MVP]

Luhar said:
I'm attempting to port some C# code over to VB.Net. It was going well
until
I hit the following code:

public virtual event PInputEventHandler KeyDown {
add { handlers.AddHandler(keyDownEventKey, value); }
remove { handlers.RemoveHandler(keyDownEventKey, value); }
}

It appears that one can declare Add and Remove accessors within an event
declaration in C#. Is there any way to do this in VB.Net?

In currently released final versions of VB.NET, there is no way to do that.
VB 2005 will include a similar way to archieve what's shown in the C#
snippet above.
 
G

Guest

Thanks for the information. That's what I was afraid of. Do you have any
suggestions for a workaround in VB.Net 2003? Is there some way I can detect
if an event handler is attached or detached?

Thanks again.
 

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

Top