Xaisoft
Xaisoft

Reputation: 46591

Whats the difference between the following object Instantiation in VB.NET?

If I create a class in VB called Test, I noticed I can instantiate it like:

Dim test As New Test

or

Dim test As New Test()

What is the difference?

Upvotes: 2

Views: 638

Answers (2)

Jacob Ewald
Jacob Ewald

Reputation: 2178

There isn't one. Both versions will call the parameter-less constructor of the Test class. The second one just has parentheses.

Upvotes: 1

Mark
Mark

Reputation: 3777

There's no difference, they are the same, VB.NET will ignore the () since no parameters are being passed in.

Upvotes: 6

Related Questions