Hello:
I have an application with two Windows (Window1 and Window2). When I click a Button on Window1, it opens Window2 (so far so good).
I created an overloaded Constructor that takes a value (Window2 Constructor(string)) (so far so good).
Is there a way to prevent the use of the default constructor and use the one with the parameter instead by default?
The default constructor method is inherited from the superclass (DesktopWindow). If you add a constructor to your subclass that matches the inherited constructor, then this “override” constructor will be called instead. Then, if you make the override constructor’s scope private it will not be callable from outside of the subclass itself, making the superclass’s default constructor impossible to call.
i.e.
Class Window2
Inherits DesktopWindow
Private Sub Constructor()
// this constructor matches the superclass's default
// constructor, meaning it will be used instead. But it's
// private so effectively invisible
End Sub
End Class
2 Likes