The requested page is not available for the requested platform. You are viewing the content for Default platform.

Add Missing Constructors

Adds base class constructors to a descendant class. Places the cursor on the first generated constructor and drops markers to other constructors, if any.

Availability

From the context menus or via shortcuts:

  • when the edit cursor or caret is on a class name within its declaration, provided that the base class contains at least one constructor that is not implemented in the current class.

Example

class BaseClass
{
    public BaseClass(int value)
    {
        a = value;
    }
    private int a;
}
class TestClass: BaseClass
{
}
Public Class BaseClass
    Public Sub New(ByVal value As Integer)
        a = value
    End Sub
    Private a As Integer
End Class
Public Class TestClass
    Inherits BaseClass

End Class

Result:

class BaseClass
{
    public BaseClass(int value)
    {
        a = value;
    }
    private int a;
}
class TestClass: BaseClass
{
    public TestClass(int value)
        : base(value)
    {
}
}
Public Class BaseClass
    Public Sub New(ByVal value As Integer)
        a = value
    End Sub
    Private a As Integer
End Class
Public Class TestClass
    Inherits BaseClass
    Public Sub New(ByVal value As Integer)
        MyBase.New(value)
End Sub

End Class