Purpose
Adds all constructors declared in the parent types to the current class. Use this Code Provider to add all required constructors at once.
Availability
Available when the caret is on the name of the class, assuming it misses one or more inherited constructors.
Usage
Place the caret on a class name.
Note
The blinking cursor shows the caret’s position at which the Code Provider is available.
public class Person {
public Person(string FullName) { }
public Person(string FirstName, string LastName) { }
}
class │Customer: Person {
}
Public Class Person
Public Sub New(FullName As String)
End Sub
Public Sub New(FirstName As String, LastName As String)
End Sub
End Class
Friend Class │Customer
Inherits Person
End Class
- Press the Ctrl + . or Ctrl + ~ shortcut to invoke the Code Actions menu.
- Select Add Missing Constructors from the menu.
After execution, the Code Provider adds all missing constructors to the class.
public class Person {
public Person(string FullName) { }
public Person(string FirstName, string LastName) { }
}
class Customer: Person {
public Customer(string FullName) : base(FullName) {
}
public Customer(string FirstName, string LastName) : base(FirstName, LastName) {
}
}
Public Class Person
Public Sub New(FullName As String)
End Sub
Public Sub New(FirstName As String, LastName As String)
End Sub
End Class
Friend Class Customer
Inherits Person
Public Sub New(FullName As String)
MyBase.New(FullName)
End Sub
Public Sub New(FirstName As String, LastName As String)
MyBase.New(FirstName, LastName)
End Sub
End Class