Inheritage and classes

  • Thread starter Thread starter Summa
  • Start date Start date
No - multiple inheritance is not possible in C# (nor any .Net language, I
believe).

You CAN, however, inherit from as many interfaces as you want, just only 1
class.

Adam Clauss
(e-mail address removed)
 
No, you cannot. C# does not support multiple inheritance of classes. But
you do multiple interface inheritance instead.

I hope this helps,

Jose Luis Manners, MCP
 
C# doesn't support multiple inheritence.
Plus, it's often a sign of a bad design.

You *can* implement multiple interfaces though, and each interface can
derive from multiple interfaces.
 
Hi,

Just a "thanks" to all of you :)

I havent noticed interfaces before, but from what I can read, its just a
template class kinda. I still have to implement all functionality in the
Class that inherits them. So what Im really inheriting is just "contracts"
of how the structure must look like. Correct?
 
By simulating multiple inheritance via interfaces, you just get the
kind of mess VB6 programmers used to create by using interfaces to
simulate single inheritance.

Use interfaces for what they are intended for. There is no multiple
inheritance in .net, and for good reason - it sucks and probably
means you have a bad design. If you try to fake it with interfaces,
you then have a mess on top of a bad design.
 
Back
Top