2 // Tests that explicit and normal implementations of methods are handled
3 // properly. Before we used to have the normal method implementation
4 // "implement" the classes, so that it would go into an infinite loop.
7 // Now explicit implementations are defined first.
11 public interface IDiagnostic
15 public interface IAutomobile
20 public class MyCar
: IAutomobile
, IDiagnostic
{
21 public bool diag_stop
, car_stop
, auto_stop
;
23 void IDiagnostic
.Stop() {
29 IAutomobile self
= (IAutomobile
)this; // cast this
30 self
.Stop(); // forwarding call
33 void IAutomobile
.Stop()
40 public static int Main ()
42 MyCar car1
= new MyCar();
43 car1
.Stop(); // calls the IAutomobile.Stop implementation
45 IDiagnostic car2
= new MyCar();
48 IAutomobile car3
= new MyCar();
57 Console
.WriteLine ("ok");