No Equals on interfaces

M

Michi Henning

Jay B. Harlow said:
However! you have not proven that an Interface inherits from System.Object.
If anything the other leg of this thread on Reflection reinforces my point.

My point is that within VB.NET (.NET really) interfaces DO NOT inherit from
System.Object. This is not a bug, this is how Interfaces have been defined
in VB.NET.

That is how VB.NET behaves yet (even though its specification says the
opposite).
Further that C# makes it appear that they do as a benefit for developers, C#
can do this because it knows that you need an object to implement the
Interface, not because the interface inherits from System.Object.

But VB.NET knows the same thing, doesn't it? In VB.NET, I also need an
object to implement the interface. At run time, a reference is either
null or it points at an instantiated object. All objects provide the methods on
System.Object, meaning that there is no reason to prohibit invoking methods
on System.Object via an interface reference.

Cheers,

Michi.
 
J

Jay B. Harlow [MVP - Outlook]

Michi,
But VB.NET knows the same thing, doesn't it? In VB.NET, I also need an

Could or does?

Which part of "in VB.NET Interfaces do not inherit from System.Object" do
you not understand?

I agree that VB.NET *could* know the same thing, however the designers of
language decided that Interfaces only inherit from other Interfaces. (7.8.1
below). Ergo that Interfaces do not inherit from System.Object (as
System.Object is a Class not an Interface).

I'm really not sure which "spec" you are referring to, the VB.NET "Spec" on
Interfaces:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbls7/html/vblrfVBSpec6_7.asp

7.8.1 "The base interfaces of an interface are the explicit base interfaces
and their base interfaces".
7.8.2 "The members of an interface consist of the members introduced by its
member declarations and the members inherited from its base interfaces".

Where does it state "implicit members from System.Object"? Considering it
explicitly states "explicit base interfaces".

I'll see if I can find some other clarification. I want to say there is an
article at http://www.panopticoncentral.net/

Hope this helps
Jay
 
J

Jay B. Harlow [MVP - Outlook]

Michi,
Looks like a documentation bug:

1. As VB.NET clearly follows what the VB.NET spec says, as evidenced by the
compile errors.
2. Calling BaseType on an Interface does not return System.Object.

Debug.WriteLine(GetType(IDisposable).BaseType, "IDisposable base
type")
Debug.WriteLine(GetType(String).BaseType, "String base type")

Prints:

IDisposable base type:
String base type: System.Object

Which IMHO clearly shows that IDisposable (an Interface) does not inherit
from System.Object.

I suspect the example was written by someone who understands the C# method
of handling Interfaces, not the VB.NET (or CLI) method.

Hope this helps
Jay
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top