I have the following abstract base class in which i have an abstract method. I need to know how to implement this abstract method in the child classes. The problem is how do I declare a class whose base is SomeBaseClass in Class B.
public abstract class A
{
protected abstract void Add<T>(T number) where T : SomeBaseClass;
}
public class B : A
{
protected override void Add<T>(T number)
{
throw new NotImplementedException();
}
}
I think you want the base class to have a type parameter, not a specific method:
public abstract class A<T> where T : SomeBaseClass
{
protected abstract void Add(T number);
}
public class B : A<C> {
protected void Add(C number) { ... }
}
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