Event declaration and firing
In VB I need to write 2 lines in Class to declare and fire event. In client (form for instance) I need to create an object with events from my class and write something in event procedure (3 more lines of code). Something like that:
'in class
<vbcode>
Public Event myEvent
'in some procedure
RaiseEvent myEvent
'in form
Private WithEvents obj As myClass
obj=New myClass
Private Sub obj_myEvent()
MessageBox.Show("Event fired")
End Sub
</vbcode>
How do I do the same stuff in C#? Unfortunately I cannot find any simple sample in my books.
Thank you
Vlad
Re: Event declaration and firing
Quote:
Originally posted by vchapran
In VB I need to write 2 lines in Class to declare and fire event. In client (form for instance) I need to create an object with events from my class and write something in event procedure (3 more lines of code). Something like that:
'in class
<vbcode>
Public Event myEvent
'in some procedure
RaiseEvent myEvent
'in form
Private WithEvents obj As myClass
obj=New myClass
Private Sub obj_myEvent()
MessageBox.Show("Event fired")
End Sub
</vbcode>
How do I do the same stuff in C#? Unfortunately I cannot find any simple sample in my books.
Thank you
Vlad
Here's a shot. You will have to modifiy this slightly to fit your needs
Code:
public eventname myevent;
/* In some procedure */
myevent(arguments);
I don't really understand what the rest of your VBCode is doing.