vb.net - Handles Me.Event vs Handles MyBase.Event -
class baseclass public event myevent(sender object, e eventargs) end class class derivedclass inherits baseclass sub derivedclasseventhandler(sender object, e eventargs) handles me.myevent 'do here end sub end class
is there difference between above , using handles mybase.myevent
, per guidance here under heading handling events inherited base class?
with simple example, there's little difference. argue using handles mybase...
it's clearer future readers of code know event comes from.
one potential reason preferring 1 or other in (unusual) situation of creating event same name in derived class - difference between me
, mybase
allows specific event you're handling:
class baseclass public event myevent(sender object, e eventargs) end class class derivedclass inherits baseclass public shadows event myevent(sender object, e someothereventargs) sub eventhandler(sender object, e eventargs) handles mybase.myevent end sub sub eventhandler(sender object, e someothereventargs) handles me.myevent end sub end class
Comments
Post a Comment