   OOP - C# solution for negotiating MI
class Rectangle : IRectangle{   //IRectangle methods   public int Top { get;set;}   public int Left { get;set;}   public int Width { get;set;}   public int Height { get;set;}}class MouseHandler : IMouseHandler{    //IMouseHandler methods    public void MouseDown(int x, int y);    public void MouseUp(int x, int y);    public void MouseMove(int x, int y);}//we want to create a "MouseHandledRect" that other classes can inherit fromclass MouseHandledRect : IRectangle, IMouseHandler{   public int Top { get;set;}   public int Left { get;set;}   public int Width { get;set;}   public int Height{ get;set;}   public void MouseDown(int x, int y){}   public void MouseUp(int x, int y){}   public void MouseMove(int x, int y){}}I think this is a valid use-case for multiple inheritance and can't figure out an elegant way to do it in C#. Is there another way, or is this the preferred solution? The problem is, Rectangles are not necessarily MouseHandled and MouseHandlers don't necessarily work exclusively with Rectangles but Rectangles and MouseHandlers all have default behaviours that should propogate down the inheritance chain. With that solution if I want to change behaviour for MouseHandlers or Rectangles, I will have to change the interface, and then reimplement in MouseHandledRect and any other that need to implement both types of behaviours which means I have some code duplication that I'd rather avoid.   
  What is a MouseHandledRect? Why does it need to exist?What things are kinds of MouseHandledRect?For that matter, what things are kinds of Rectangle? Why is there even an IRectangle - how many implementations of a rectangle can there realistically be?   ;Quote:Original post by ZahlmanWhat is a MouseHandledRect? Why does it need to exist?What things are kinds of MouseHandledRect?For that matter, what things are kinds of Rectangle? Why is there even an IRectangle - how many implementations of a rectangle can there realistically be?MouseHandledRects would be gui-hotspots where the mouse can interact with an area. A button would inherit from a MouseHandledRect. Rectangles are rectangular layout areas for gui elements - but also used for drawing and other functionality related specifically to rectangles like Contains(point) - someRectangle MouseHandledRect  |    |LabelSliderThinking about it now, maybe this makes sense:class Rect : IRectangle{   public int Top{get;set;}   public int Left{get;set;}   public int Width{get;set;}   public int Height{get;set;}}class MouseHandler{    public void MouseDown(int x, int y){}    public void MouseUp(int x, int y){}    public void MouseMove(int x, int y){}}class ControlRect : MouseHandler, IRectangle{    Rect layout = new Rect();    public int Top{ get {return layout.Top} set{layout.Top=value;}    public int Left{ get {return layout.Left} set{layout.Left=value;}    public int Width{ get {return layout.Width} set{layout.Width=value;}    public int Height{ get {return layout.Height} set{layout.Height=value;}}The reason for IRectangle is so that I can maintain a collection of all Rectangles in a context, whether they are MouseHandled or not.   ;  I can't see any way that a button IS A mouse handler, which would be the use-case for inheritance. Instead a button HAS A mouse handler, making this a use-case for composition instead...   