Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
So I am declaring a new event for a class and I get to the point where I need to define the event args. All I really need to pass through is a text string.

Now I usually follow some diligent best practice guide that I remember reading awhile ago that says you should define a new class to hold your event args instead of just passing the event data along in the class like so:

Public Event EventName (sender As Object, message As String)


So I do it like so:

Public Class EventNameEventArgs : Inherits EventArgs <br /><br />   Public Property Message() as String <br /><br />End Class <br /><br />Public Event EventName (sender as Object, e As EventNameEventArgs) 


The problem is, I have the feeling that I am the only person on the face of the planet doing this :), but I have not seen any code form others that does NOT do this. I just want to get a general consensus for the group here...

I tend to think that yes, it is a good idea because it allows for the addition of new arguments latter on without breaking the existing code that references the event but...

Comments? Flames?

Please, no remarks about VB either...

Posted

1 solution

This will help: Event Arguments (EventArgs)[^]

 
Share this answer
 


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900