[Mono-list] Interface collisions

Jonathan Pryor jonpryor@vt.edu
10 Dec 2002 10:30:19 -0500


Inline...

On Tue, 2002-12-10 at 08:01, Quentin DELANCE wrote:

<snip/>

> My example  (InterfaceClash.cs) :
> 
> ---
> $ cat InterfaceClash.cs
> using System;
> 
> interface I1 { void F(); }
> interface I2 { int F(); }
> 
> public class TestClass : I1, I2 {}
> ---
> 
> (It is not possible to implement void F() and int F() at the same time)

Just a correction.  It *is* possible to implement I1 and I2 at the same
time.  You just need to explicitly qualify the method implementations:

        interface I1 {void F();}
        interface I2 {int F();}

        class Test : I1, I2 {
          void I1.F() {
          }

          int I2.F() {
            return 42;
          }
        }

The above compiles properly on mcs.  (It should work with csc -- I've
done similar things before -- but I don't want to boot my Windows box
just to test this.)

 - Jon