abstract class MyClass
{
MyClass Load(string filename)
{
...
}
}
class MyInheritor : MyClass
{
MyInheritor Load(string filename)
{
...
}
}
class MyInheritor2 : MyClass
{
...
}
The goal is to enforce the MyClass return type in the Load(string) function to return a type the same as the inheritor, as in MyInheritor's implementation of Load(string).
I guess my question is is it possible, in a parent class, to force a child class to use its own type as a return type, so as to avoid allowing MyInheritor.Load(string) to return a type MyInheritor2?
I'd like to avoid generics, as it does not enforce using the specific child class, unless there is some other way of using <T> that I'm not aware of.
Thank you!

New Topic/Question
Reply




MultiQuote







|