I have an abstract class A
with one abstract method.
This class is inherited by another class, B
, that should not implement the abstract method.
Now another class, C
, needs to inherit from class B
and implement the method defined in class A
.
How can I do this?
You would need to mark class B
as an abstract class as well if it's not going to implement all of the abstract members of its base class. Then, just override as normal in class C
.
Example:
public abstract class A
{
public abstract void DoStuff();
}
public abstract class B : A
{
// Empty
}
public class C : B
{
public override void DoStuff()
{
Console.WriteLine("hi");
}
}
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