Jump to content
  • Advertisement
Sign in to follow this  
Kryptus

C# Events

This topic is 4713 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm finding C# events to be a bit hard to learn. I understand them in VB but it's a lot different in C#. In VB I would use the following for example: Client is a network class I have created and also contains events that are raised when a client connects, disconnects, etc. Dim myClient As Client AddHandler myClient.Connected, AddressOf OnConnected AddHandler myClient.Disconnected, AddressOf OnDisconnected Public Sub OnConnected() Console.WriteLine("User has connected") End Sub That's the gist. I hope you understand, being that it's just an example. How would I complete the same in C#? I have some events already declared as delegates and events but I don't know how to "AddHandler" or so to speak. Thanks.

Share this post


Link to post
Share on other sites
Advertisement
d3d_device.DeviceLost += new System.EventHandler(this.OnLostDevice);

Taken from my Direct3D wrapper. Of course, it depends on the type of the event you want to override.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!