✅ Multiple inheritance question
I have a partial class webform that is inheriting a base page class. Inside it there are multiple references to base methods.
I am required to make a similar one with ever so slightly different functionality that has to be in a separate aspx.
The question is can I use Multiple inheritance to avoid copy pasting the code over into the new one and making the changes? Is it possible to just inherit the partial and somehow access the base methods required for it to function?
7 Replies
c# doesnt support multiple inheritance
thankfully
its hard to recommend what to do in a case like this without seeing the code
The gist of it is copy paste code but i am trying to find out if i can avoid copy pasting everything and doing it more elegantly.
The new webform that will provide the service is 99% identical to the old but it has it's own unique flares and features in a sense.
I can't make it inherit the old partial class which inherits the base since I don't think it will allow me to access the base methods right?
You cannot make a class that inherits from two classes, but you can turn your existing form into a new 'base class' which contains the shared code, and make your two pages inherit from your base class
it's possible for a class to inherit from a class, which itself inherits from a diffrent class
possible:
not possible
okay cheers for the explanation and the to do it more elegantly i need to do a full refactor of the service which given the deadline of today is not possible for the release, for now copy pasta it is and future releases with the refactored version
welcome to developer life!
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.