Permalink
Cannot retrieve contributors at this time
Fetching contributors…
| class Test | |
| { | |
| static void Main() | |
| { | |
| SampleClass sc = new SampleClass(); | |
| IControl ctrl = (IControl)sc; | |
| ISurface srfc = (ISurface)sc; | |
| // The following lines all call the same method. | |
| sc.Paint(); | |
| ctrl.Paint(); | |
| srfc.Paint(); | |
| } | |
| } | |
| interface IControl | |
| { | |
| void Paint(); | |
| } | |
| interface ISurface | |
| { | |
| void Paint(); | |
| } | |
| class SampleClass : IControl, ISurface | |
| { | |
| // Both ISurface.Paint and IControl.Paint call this method. | |
| public void Paint() | |
| { | |
| Console.WriteLine("Paint method in SampleClass"); | |
| } | |
| } | |
| // Output: | |
| // Paint method in SampleClass | |
| // Paint method in SampleClass | |
| // Paint method in SampleClass |