C# alternative for WithEvents  
Author Message
Xancholy





PostPosted: Visual C# General, C# alternative for WithEvents Top

I have a simple vb codeline that I need to find a code translation for in C# but I dont find withevents...

Here's the VB code anyway...

Dim WithEvents dx As Video

What would the above be with C# Appreciate any help.

Thanks


Visual C#16  
 
 
David Anton





PostPosted: Visual C# General, C# alternative for WithEvents Top

private Video dx;

"WithEvents" is not relevant in C#.

David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C# to C++ converter, VB to C++ converter
Instant Python: VB to Python converter



 
 
Xancholy





PostPosted: Visual C# General, C# alternative for WithEvents Top

Thanks for that reply.

 
 
Scott Nonnenberg MSFT





PostPosted: Visual C# General, C# alternative for WithEvents Top

For a little more insight into the problem, I should mention the reason WithEvents isn't relevant in C#. The "WithEvents" keyword in VB is intimately tied with the "Handles" keyword, which allows autowiring of events. In C#, neither of these keywords exist and you have to manually wire up your events - see the "+=" operator.

Hope this helps,
Scott