static void Main(string[] args) { MyNode n = new MyNode(); MyContainer c = new MyContainer(); c.AddChild(n); OtherNode o = new OtherNode(); o.AddChild(o); }
static void Main(string[] args) { MyNode n = new MyNode(); MyContainer c = new MyContainer(); c.AddChild(n); MySubNode s = new MySubNode(); // // This does not work because it tries to fill the generic in the // extension method with <MySubNode, MyContainer>, which does not // fulfil the constraint "where Container : Node". // //c.AddChild(s); OtherNode o = new OtherNode(); o.AddChild(o); }