GendoIkari
Member
- Joined
- Mar 20, 2009
- Messages
- 20
- Programming Experience
- 1-3
It seems that in VB.net, all my instance members are accessible as though they were shared members, as long as my class inherits Windows.Forms.Form.
For example:
As expected, MyNonFormClass.ShowTest1() throws a compiler error, because ShowTest1 is not a shared member. But The second line, MyFormClass.ShowTest2(), does not throw an error, even in runtime.
Is this correct behavior? Why would inheriting from Windows.Forms.Form cause instance members to be accessible as shared members? Also, this does not happen in C#... the exact same code in C# works as expected.
Thanks!
For example:
Public Class MyNonFormClass
Public Sub ShowTest1()
MessageBox.Show("test")
End Sub
End Class
Public Class MyFormClass
Inherits System.Windows.Forms.Form
Public Sub ShowTest2()
MessageBox.Show("test")
End Sub
End Class
Public Class MyCallingClass
Public Sub RunTests()
MyNonFormClass.ShowTest1()
MyFormClass.ShowTest2()
End Sub
End Class
As expected, MyNonFormClass.ShowTest1() throws a compiler error, because ShowTest1 is not a shared member. But The second line, MyFormClass.ShowTest2(), does not throw an error, even in runtime.
Is this correct behavior? Why would inheriting from Windows.Forms.Form cause instance members to be accessible as shared members? Also, this does not happen in C#... the exact same code in C# works as expected.
Thanks!
Last edited: