I will give an example so that you can better understand what I mean:
public class Base
{
public Base Common()
{
return this;
}
}
public class XBase : Base
{
public XBase XMethod()
{
return this;
}
}
I want to be able to do something like:
var a = new XBase().Common().XMethod();
but this is not possible because it Common()returns Base, XMethod()not defined in Base.
Is there any possible way I could do this?
I ask because I have BaseComponentmany others Componentsthat inherit this class, and I have to declare common methods in each of them, just to call base.Method()inside.
Thank you for your help.
PS: without using generics and specifying the type of child:
var a = new XBase().Common<XBase>().XMethod();
source
share