You can not.
However, you could set one constructor in FatherClass as follows:
protected FatherClass(string val1, string val2) {}
What forces subclasses to call this constructor is to βencourageβ them to create the constructor string val1, string val2 , but it does not give it a mandate.
I think you should consider an abstract factory template instead. It will look like this:
interface IFooFactory { FatherClass Create(string val1, string val2); } class ChildClassFactory : IFooFactory { public FatherClass Create(string val1, string val2) { return new ChildClass(val1, val2); } }
If you need to instantiate a subclass of FatherClass, you use IFooFactory, not directly. This allows you to specify the signature (string val1, string val2) to create them.
Matt howells
source share