They are the same at the class level - it's just that the VB.NET
compiler does not enforce the distinction between shared and instance
members. Which is bad, IMHO.
Actually I just realized whats going on is not what you guys are
saying.
Try this:
Dim x as MessageBox
Dim y as MessageBox
' Note you cannot instantiate a new
' one due to private constructor
x.Show("test")
y.Show(Cbool(x is y))
x and y refer to same instance ("true" is displayed on the second
line).
Without the first line you cannot compare x to y because they are not
yet set to the "global" static messagebox.
in VB.net, it appears that Shared gives you THE OPTION of calling a
method without instantiating an instance... but you can do so if you
want.
in C#, static means you MUST call the method without declaring an
instance.
Big difference.
My guess is that this is a language design flaw.. not really a flaw in
C# or VB.Net, but a flaw in the sense that the design team strived to
maintain the behavior people were used to in earlier versions of those
languages (VB6 and C++), thus the difference in behavior.
If you need proof, create a new vb class with a simple shared sub, try
instantiating an x and y variable. You can do so, and the test to see
if x = y above will return false because they are not the same, like
the case of the global MessageBox class.
My question now is why is the MessageBox class "system global" so to
speak, whereas the class created in VB.net is not?