c# - How to avoid implementing empty constructors in derived classes? -


i have base class has large number of derived classes, , base class has several constructors. in derived classes have implement empty constructors forward arguments base constructors. possible somehow tell c# use derived constructors?

for example, if using base class.

 class basetool  {       public basetool(string arg1, string arg2)       {           // stuff.       }        public basetool(string arg1)       {           // stuff.       }        public basetool(int arg1)       {           // stuff.       }   } 

i have implement above constructors arguments, , call : base(...) forward them derived class. resulting in lot of classes have empty constructors. seems lot of wasted code.

constructors not inherited base classes, there no way around declaring constructors in each derived class. however, automate repetitive task with, example, t4 templates.


Popular posts from this blog

node.js - How do I prevent MongoDB replica set from querying the primary? -

c# - Randomly pick a specific int from a 2D Array -

php - Angularjs http.delete is not working after deploying project on server -