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

  • Thread starter Thread starter vighnesh
  • Start date Start date
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
 
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
 
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".
 
Back
Top