I'm working on a project and I need some help with C# constructors. Let's say I have the following;
Now, I want truck to inherit from from automobile because there are methods that I want to reuse. However, I do not want to the call the auto constructor, I want to call the vehicle constructor instead.Code:public class vehicle { public vehicle() { //do some initialization for all vehicles } } public class automobile : vehicle { public auto : base { // do specific initialization for auto } } public class truck : auto { public truck : base { // do specific initialization for truck } }
Anyone know of a way I can do that?
Thanks in advance.




Reply With Quote