I have this base class:
public abstract class Parent {
public void DoSomething() {
var c=new GenericClass<**ThisInstanceType**>();
c.DoYourThing();
}
}
What should I put instead ThisInstanceType in order to use generics with the type of “this” (the current child instance)?
I cannot change the declaration of Parent.DoSomething(). It cannot be void DoSomething<T>().
You could do:
and if necessary you could add:
public interface IParent
{
void DoSomething();
}
BTW: If you include the full complete real life example, I might be able to give you a better solution
The other solution would be to use reflection to get the proper type and call the method at runtime…