3 public interface IVehicle
{
9 public interface IWalker
{
13 public class Base
: IVehicle
{
14 int IVehicle
.Start () { return 1; }
15 public int Stop () { return 2; }
16 public virtual int Turn () { return 3; }
17 public int Walk () { return 1; }
20 public class Derived1
: Base
{
21 // replaces Base.Turn + IVehice.Turn
22 public override int Turn () { return 4; }
25 public class Derived2
: Base
, IVehicle
{
26 // legal - we redeclared IVehicle support
27 public new int Stop () { return 6; }
28 // legal - we redeclared IVehicle support
29 int IVehicle
.Start () { return 5; }
30 // replaces IVehicle.Turn
31 int IVehicle
.Turn () { return 7; }
33 public override int Turn () { return 8; }
36 public class Derived3
: Derived1
, IWalker
{
42 Derived1 d1
= new Derived1 ();
43 Derived2 d2
= new Derived2 ();
44 Derived3 d3
= new Derived3 ();
47 Base rb
= new Base ();
52 if (((IVehicle
)d1
).Turn () != 4)
55 if (((Base
)d2
).Turn () != 8)
58 if (((IVehicle
)d2
).Turn () != 7)
64 if (((IVehicle
)b2
).Turn () != 7)
67 if (((IVehicle
)rb
).Stop () != 2)
70 if (((IVehicle
)d1
).Stop () != 2)
73 if (((IVehicle
)d2
).Stop () != 6)
79 //Console.WriteLine ("TEST {0}", ((IVehicle)b2).Turn ());