I have a class that I would like to inherit. that is, ExpenseForm must inherit from the table. The spreadsheet is provided by a third party: I cannot change it.
But instances of the parent class are usually generated by the static method:
Spreadsheet myExpenses = Spreadsheet.Open(filename);
(And Spreadsheet implements iDisposable, so the above statement is actually at the top of the section, but I don't think it really affects that.)
I would like to have
ExpenseForm myExpenses = ExpenseForm.Open(filename);
This fails, of course, since ExpenseForm.Open (inherited from Spreadsheet) returns a Spreadsheet object.
What is the best way to solve this problem? Maybe extension methods? (I have no experience with them.)
I went in a different direction; ExpenseForm now has an instance of the table. (This feels a little messier, as I have to keep track of my disposable object in order to clear it when done.) But it seems like I am missing a way to solve the original inheritance problem.
source share