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
2008-12-08 22:54:20
Inheriting an interface isn't really inheritance though...
Orion Edwards
2008-12-08 23:12:31
@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
2008-12-09 19:55:09
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
2009-04-28 12:58:39
+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
2008-12-08 22:55:01