I have ClassA:
public class ClassA<T>
I have a generic method in ClassA:
protected TP FunctionA<TP>(Expression<Func<T, TP>> p)
{
//Code for method here
}
ClassB derives from ClassA:
public class ClassB : ClassA<ClassB>
ClassC derives from ClassB:
public class ClassC : ClassB
When creating ClassC like in the example above, ClassA will still have a type of ClassB because ClassC derives from ClassB, and ClassB is what sets the type of ClassA to ClassB.
What I am wondering is how do I derive from ClassB while at the same time setting ClassA type to ClassC and also ClassB still needs to be able to be used on its own without needing to derived from.
Thanks!
ClassB is no longer generic. Nor is ClassC. If you want to keep it generic then the pattern is: