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

V

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
 
M

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
 
H

Herfried K. Wagner [MVP]

vighnesh said:
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".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top