(Follows on from yesterday's post.)
Because WithEvents fields are wrapped in a property, passing them by reference is should be a problem, but it magically seems to work! This is an example of VB.NET continuing in its fine tradition of "protecting" the developer from messy details.
Reflector reveals that if you write this:
Friend WithEvents Button1 As System.Windows.Forms.Button
Private Sub X()
Y(Button1)
End Sub
Private Sub Y(ByRef a As Button)
End Sub
the VB compiler generates code for X() like this:
Private Sub X()
Dim button1 As Button = Me.Button1
Me.Y(button1)
Me.Button1 = button1
End Sub
No comments:
Post a Comment