I have a virtual method on a base class. Each time I override it, I want to return different object types. I know this is not possible, but what would be the best way to handle this situation?
Example of base method:
public virtual void clickContinue()
{
//click the continue button
}
And the method that overrides it:
public override myObject clickContinue()
{
//click then continue button
//return myObject
}
I need to do several similar overrides, all returning different objects. Again, I know this can't be done the way it's done above - I trying to figure out the best way to handle this situation.
I know this is not possible, but what would be the best way to handle this situation?
If you don't need a default implementation, you can potentially make the class generic, and return the generic type:
abstract class YourBase<T>
{
abstract T ClickContinue();
}
class YourOverride : YourBase<MyObject>
{
override MyObject ClickContinue()
{
//...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With