I\'ll give an example, so you can better understand what i mean:
public class Base
{
public Base Common()
{
return this;
}
}
pub
You could make Base
generic and use the Curiously Repeating Template Pattern:
public class Base<T> where T : Base<T>
{
public T Common()
{
return (T)this;
}
}
public class XBase : Base<XBase>
{
public XBase XMethod()
{
return this;
}
}
Then you can just use:
var a = new XBase().Common().XMethod();
Have Base
be abstract and not implementing XMethod and have the classes overriding XMethod
should do it I guess?
public abstract class Base<T>
{
public Base Common()
{
return this;
}
public abstract T XMethod();
}
public class XBase : Base<XBase>
{
public override XBase XMethod()
{
return this;
}
}