Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

(New Object()).Method() in VB.net

Apparently, this does not work.

WHY ???????

I don't want to do all this just to call my function:

Dim x as new Object()
x.Method()

Why do I have to do this in two lines when I can in one.

like image 503
Tomasi Avatar asked Mar 08 '10 23:03

Tomasi


People also ask

How does VB.NET creates the .NET object?

In VB.NET, when we pass one or more arguments to a constructor, the constructor is known as a parameterized constructor. And the object of the class should be initialized with arguments when it is created. Let's create a program to use the parameterized constructor to pass the argument in a class.

What method is called when an object is created with the new method?

Instantiation: The new keyword is a Java operator that creates the object. As discussed below, this is also known as instantiating a class.

How do you initialize a new object?

Objects can be initialized using new Object() , Object. create() , or using the literal notation (initializer notation). An object initializer is a comma-delimited list of zero or more pairs of property names and associated values of an object, enclosed in curly braces ( {} ).


1 Answers

You need to add the Call keyword.

    Call New Page().DataBind()

This causes the object to be created before passing to the Call statement.

Yes, I agree, (New Object()).Method() seems more intuitive.

like image 198
AMissico Avatar answered Sep 20 '22 10:09

AMissico