This question is similar to this one. The difference is that I'd like to have two base classes.
Example:
public class Circle
{
private string _radius { get; set; }
public Circle Radius(string radius)
{
_radius = radius;
return this;
}
}
public class Box
{
private string _width { get; set; }
public Circle Width(string width)
{
_width = width;
return this;
}
}
public class CircleAndBox : Circle, Box // Can't do in c#
{
// should contain methods from both Circle and Box, but return CircleAndBox
}
Maybe Circle and Box was not the best example. Basically they represent classes with different properties and methods. Class CircleAndBox just happens to have the same properties and methods as both Circle and Box. CircleAndBox may have additional properties and methods that do not exist neither in Circle nor in Box.
Desired Result
I should be able to write:
var circle = new Circle().Radius("5");
var box = new Box().Width("6");
var circleAndBox = new CircleAndBox().Radius("5").Width("6");
It would be Super if:
When I add a method to Circle
or Box
class, I should not touch CircleAndBox
class. Just like with regular inheritance from a single class, CircleAndBox
should automatically inherit all public methods from both Circle
and Box