views:

1914

answers:

2

Is multiple inheritance possible in VB .Net? If so, what is the syntax?

+6  A: 

Short answer: No

Slightly longer answer: Yes, if you inherit multiple interfaces, and a single base class. Since this is usually the reason for MI (you want to implement multiple interfaces), it's usually enough. However, in those rare instances where "real" MI is useful, .NET prevents you from doing it.

Harper Shelby
Inheriting an interface isn't really inheritance though...
Orion Edwards
@Orion Edwards: how is it not? Inheritance defines "is a" relationship, and interfaces are one way to define what an object 'is'. If I inherit ISerializable, I'm saying "I am an ISerializable", and treating me as an ISerializable works as expected.
Harper Shelby
Further to @Harper Shelby's comment, a voluntary application of this sort of restriction is usually viewed as a best practice in C++ (instead of interfaces you'd have pure abstract base classes).
Richard
+3  A: 

It's possible in a restricted manner in VB.Net in the same way that it is in C#: via Interfaces. Since an interface works out to essentially a pure-abstract base class, you can inherit from as many of those as you need and from one real class.

Joel Coehoorn