Say you have a parent class with lots of subclasses. If the constructor of the parent gets a new parameter you would have to change all the children constructors, too. Is there a way to inherit the parent constructor without naming all the parameters?
Code that I want to write, but gives the error 'There is no argument given for the formal parameter...':
public abstract class A
{
public A(someType somePar)
{
}
}
public class B : A
{
}
Annoying solution:
public abstract class A
{
public A(someType somePar)
{
}
}
public class B : A
{
//If there is a new parameter, this would need to change
B(someType somePar) : base(somePar)
{
}
}
Sorry if there is an obvious solution to this, I'm writing for the first time with C#