I’m playing around with implementing a fluent interface for some of my code.
However when I extend a class that uses this method I have to add in an ugly cast.
Allow me to demonstrate.
public class Base
{
public Base Add()
{
return this;
}
}
public class Child : Base{}
Now what I want to type is this
Child myChild = new Child()
.Add()
.Add()
.Add();
But what I have to type is this
Child myChild = (Child) new Child()
.Add()
.Add()
.Add();
Is there a way around this?