tags:

views:

71

answers:

2

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 2 lines when I can in one. This is really pissing me off.

+4  A: 

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.

AMissico
Great, I would have never thought of that.
diamandiev
BTW I was thinking would it not have been nice if we could just call the New method like a regular one? Like this Object.New(). Too bad this is not the case.
diamandiev
A: 

I'm assuming you don't want to make the method static?

public class foo
    public shared sub sayFoo
        console.writeline("foo")
    end sub
end class

then call sayFoo like.

foo.sayFoo