Accessor declarations for events in VB.Net

  • Thread starter Thread starter Guest
  • Start date Start date
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.
 
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.
 
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.
 
Back
Top