Syntax – can be a class method called at New without a helper variable?

Having sample trivial class

Class A
    Property Property1 As Integer = 5
    Sub Action1()
        Debug.Print(Property1.ToString())
    End Sub
End Class

I can always call Action1() like

Dim instanceA As New A
instanceA.Action1()

But can I call the method without using the variable? Something like

(New A).Action1()

I’m getting syntax error at the 1st character when attempting that.


Source: syntax

Leave a Reply