I have see code like this
Dim s as something = new something
Dim s as new something
what's the difference? is there any?
I have see code like this
Dim s as something = new something
Dim s as new something
what's the difference? is there any?
I believe all you're doing is specifically casting something as something.
There is no difference. Those signatures are identical as far as VB is concerned. One has less typing though :)
A slight difference.
The first allows you to do:
Dim s as ParentType = new InheritedType
The second doesn't.
The "advantage" of this is s
can be a number of different types related to ParentType without it exploding at runtime.
There is no difference.
You may see some developers that prefer
Dim s as something = new something
over
Dim s as new something
This is probably a hold over from Vb6 (as new
in VB6 does more that you'd think and has nasty side effects).
It's one of the things that was "fixed" with Vb.Net
Just to reiterate, in Vb.Net the statements are Equivalent i.e. both statements will build exactly the same IL.