Consider a class MyFormthat contains a hidden implementation Show(). It also contains a method CreateForm()that takes an instance of the form and calls a shaded sub:
Public Class MyForm
Inherits Form
Public Shadows Sub Show()
MessageBox.Show("Shadowed implementation called!")
End Sub
End Class
...
Public Sub CreateForm(ByVal childForm As MyForm)
childForm.MdiParent = Me
childForm.Show()
childForm.Focus()
End Sub
When called with CreateForm(New MyForm()), the shadow implementation is correctly called Show(). Now consider the following general implementation:
Public Sub CreateForm(Of T As Form)(ByVal childForm As T)
childForm.MdiParent = Me
childForm.Show()
childForm.Focus()
End Sub
It called CreateForm(Of MyForm)(New MyForm())this strongly typed general method never causes shadowed method.
Is this a mistake, or am I missing something?
source
share