Home All Groups Group Topic Archive Search About

Difference between Dim I as ineteger and Dim I as New Integer

Author
4 May 2007 12:15 PM
vighnesh
Hi Folks

Please let me know the difference between the following statements.

Dim i as Integer
Dim i as New Ineger

As I tested both declares a variable 'i' of type integer intialized to value
'0'.
Please let me know the significance of  'New' keyword in the declaration. I
suppose 'New' is used to create an object of a class, but here 'Integer' is
not a Reference Type. The same with the following statements.

Dim s as String
Dim s as New String("s",1)

Thanking you in advance.

Regards
Vighneswar

Author
4 May 2007 1:58 PM
Michel Posseth [MCP]
There is no difference

except of typing length and ambigity to other .Net languages  ( mather of
personal prefernce i would call this )

regards

Michel Posseth


Show quoteHide quote
"vighnesh" <vighn***@nannacomputers.com> schreef in bericht
news:u0KtbXkjHHA.2272@TK2MSFTNGP02.phx.gbl...
>
> Hi Folks
>
> Please let me know the difference between the following statements.
>
> Dim i as Integer
> Dim i as New Ineger
>
> As I tested both declares a variable 'i' of type integer intialized to
> value '0'.
> Please let me know the significance of  'New' keyword in the declaration.
> I suppose 'New' is used to create an object of a class, but here 'Integer'
> is not a Reference Type. The same with the following statements.
>
> Dim s as String
> Dim s as New String("s",1)
>
> Thanking you in advance.
>
> Regards
> Vighneswar
>
>
Author
5 May 2007 4:37 PM
Herfried K. Wagner [MVP]
"vighnesh" <vighn***@nannacomputers.com> schrieb:
> Please let me know the difference between the following statements.
>
> Dim i as Integer
> Dim i as New Ineger
>
> As I tested both declares a variable 'i' of type integer intialized to
> value '0'.

The two lines are semantically equivalent.

> Dim s as String
> Dim s as New String("s",1)

These lines are semantically different as 'String' is a reference type.  The
first variable will be initialized to 'Nothing', the second will have the
value "s".

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>