No Equals on interfaces

From: Michi Henning (michi_at_zeroc.com)
Date: 09/03/04


Date: Fri, 03 Sep 2004 14:20:38 +1000

Hi,

the following code won't compile, but I believe it should:

Interface X
End Interface

Module M
     Sub Main(ByVal args As String())
        Dim iref As X
        iref.Equals(iref) ' 'Equals' is not a member of 'vb.I'.
     End Sub
End Module

The compiler complains that X does not have a member Equals.
(The same complaint is issued for the other methods of System.Object:
GetHashCode, GetType, and ToString.)

This seems wrong, given that C# compiles the equivalent code
without complaint.

Also, the following works fine:

Dim iref As X
Dim oref As Object = iref
oref.Equals(oref)

Clearly, if there is an implicit conversion from X to Object,
then X must have the members of Object (otherwise, implicit
conversion would have to be illegal.)

Does anyone know whether this problem is fixed for Whidbey?

Thanks,

Michi.



Relevant Pages

  • Re: VB vs. C# language challenge question
    ... you can inherit the abstract class yet still need to implement some methods ... base class to overload and then a separate interface with the undefined ... Public Sub m11() Implements i1.m1 ... I can not get it compile in VB, while in C# it is just a piece of cake. ...
    (microsoft.public.dotnet.framework)
  • Re: VB vs. C# language challenge question
    ... you can inherit the abstract class yet still need to implement some ... create a base class to overload and then a separate interface with the ... Public Sub m11() Implements i1.m1 ... I can not get it compile in VB, while in C# it is just a piece of cake. ...
    (microsoft.public.dotnet.framework)
  • Re: VB vs. C# language challenge question
    ... compile due to the compiler error BC30149: ... Does it mean that in VB interface must be implemented, ... public interface i1 { ... Public Overridable Sub m1 ...
    (microsoft.public.dotnet.languages.vb)
  • Re: VB vs. C# language challenge question
    ... Does it mean that in VB interface must be implemented, ... I can not get it compile in VB, while in C# it is just a piece of cake. ... public interface i1 { ... Public Overridable Sub m1 ...
    (microsoft.public.dotnet.languages.vb)
  • Re: VB vs. C# language challenge question
    ... compile due to the compiler error BC30149: ... Does it mean that in VB interface must be implemented, ... public interface i1 { ... Public Overridable Sub m1 ...
    (microsoft.public.dotnet.languages.vb)