Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. why multiple class inheritance is not supported in C# .NET

why multiple class inheritance is not supported in C# .NET

Scheduled Pinned Locked Moved C#
csharpoopquestion
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    For_IT
    wrote on last edited by
    #1

    Hi all can someone pls tell me why multiple class inheritance is not supported in C#.net? thanks

    R K J 3 Replies Last reply
    0
    • F For_IT

      Hi all can someone pls tell me why multiple class inheritance is not supported in C#.net? thanks

      R Offline
      R Offline
      Ravi Bhavnani
      wrote on last edited by
      #2

      From WikiPedia[^]: Multiple inheritance can cause some confusing situations (I believe they're referring to the diamond problem - see this[^] link. -- Ravi), so there is some debate over whether or not its benefits outweigh its risks. Java compromises: it allows a class to inherit interfaces from more than one parent (that is, one can specify that a class inherits all the types from its parents and must have all of the same externally exposed methods of its interface-parents, and allow the compiler to enforce that), but can inherit implementation (methods and fields) from only one parent. Microsoft's .NET languages such as C# and Visual Basic implement this interface approach as well. In contrast C++ implements full multiple inheritance. /ravi

      My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

      1 Reply Last reply
      0
      • F For_IT

        Hi all can someone pls tell me why multiple class inheritance is not supported in C#.net? thanks

        K Offline
        K Offline
        Kevin McFarlane
        wrote on last edited by
        #3

        One reason why it is not supported is that .NET was designed to be multi-language and most OO languages don't support MI. However, Eiffel .NET does (I think uniquely) support MI on .NET in a very ingenious way. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/pdc_eiffel.asp[^]

        Kevin

        1 Reply Last reply
        0
        • F For_IT

          Hi all can someone pls tell me why multiple class inheritance is not supported in C#.net? thanks

          J Offline
          J Offline
          Joe Woodbury
          wrote on last edited by
          #4

          I asked a C# instructor several years ago this question. He said it was because the designers were worried the dumb people wouldn't understand multiple inheritance. (He added that most the dumb things in C# were done for this reason.) This response is flippant, but I suspect more true than not. Multiple inheritance is very powerful and rarely used in good code, but when needed, it's really needed. The solution was interfaces. Personally, I'd rather have had multiple inheritance, but what can you do? (I also think they should have had a scoped destructor mechanism built in. I'm sure everyone has their list of complaints.)

          Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups