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 C# (and .NET) does not support multiple-class-inheritance?

Why C# (and .NET) does not support multiple-class-inheritance?

Scheduled Pinned Locked Moved C#
csharpquestionoopcareer
5 Posts 2 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.
  • S Offline
    S Offline
    Salil Khedkar
    wrote on last edited by
    #1

    I am myself not a great admirer of this feature and I understand we can still do the needful using interfaces. But I am interested in *technical reasons* why .NET guys decided to omit this feature from .NET :confused: This seems to be a favourite interview question.

    S 1 Reply Last reply
    0
    • S Salil Khedkar

      I am myself not a great admirer of this feature and I understand we can still do the needful using interfaces. But I am interested in *technical reasons* why .NET guys decided to omit this feature from .NET :confused: This seems to be a favourite interview question.

      S Offline
      S Offline
      Steve Maier
      wrote on last edited by
      #2

      Here is a little things that I read recently. C# offers only single inheritance which means that a class can have only one direct base class. This restriction is actually imposed by the CLR so single inheritance is the rule for all .NET languages. The designers of .NET acknowledge that multiple inheritance is more powerful than single inheritance; however, they decided that the extra complications and ambiguous situations that arise in the presence of multiple base classes were not worth this extra power. Steve Maier, MCSD MCAD

      S 1 Reply Last reply
      0
      • S Steve Maier

        Here is a little things that I read recently. C# offers only single inheritance which means that a class can have only one direct base class. This restriction is actually imposed by the CLR so single inheritance is the rule for all .NET languages. The designers of .NET acknowledge that multiple inheritance is more powerful than single inheritance; however, they decided that the extra complications and ambiguous situations that arise in the presence of multiple base classes were not worth this extra power. Steve Maier, MCSD MCAD

        S Offline
        S Offline
        Salil Khedkar
        wrote on last edited by
        #3

        Hey thanks buddy, that’s right. :rose: I think, I should frame my interview answer as follows: (1) As one of the core features, .NET platform targets to support multiple languages. The internal constructs of each language compiler to implement MI differ. (2) The cost of implementing MI (especially due to above mentioned reason) is quite high as MI is relatively rarely used in most OOP designs. For those rare situations, interface based MI, which does not involve much of an overhead and complexities, can be used. (3) A language or platform supporting MI becomes rather complex from developer as well as the compiler writer perspective because of the confusion involved in casting, member references ambiguity, serializing and so on. .NET aims to be a clean and intuitive platform. Howz that? ;)

        S 1 Reply Last reply
        0
        • S Salil Khedkar

          Hey thanks buddy, that’s right. :rose: I think, I should frame my interview answer as follows: (1) As one of the core features, .NET platform targets to support multiple languages. The internal constructs of each language compiler to implement MI differ. (2) The cost of implementing MI (especially due to above mentioned reason) is quite high as MI is relatively rarely used in most OOP designs. For those rare situations, interface based MI, which does not involve much of an overhead and complexities, can be used. (3) A language or platform supporting MI becomes rather complex from developer as well as the compiler writer perspective because of the confusion involved in casting, member references ambiguity, serializing and so on. .NET aims to be a clean and intuitive platform. Howz that? ;)

          S Offline
          S Offline
          Steve Maier
          wrote on last edited by
          #4

          Sounds pretty good. On my last .Net related interview I did not need to answer questions like that. There were some technical questions, but it was mainly system based, like how do you handle this situation on a web server farm. Steve Maier, MCSD MCAD

          S 1 Reply Last reply
          0
          • S Steve Maier

            Sounds pretty good. On my last .Net related interview I did not need to answer questions like that. There were some technical questions, but it was mainly system based, like how do you handle this situation on a web server farm. Steve Maier, MCSD MCAD

            S Offline
            S Offline
            Salil Khedkar
            wrote on last edited by
            #5

            Oh yeah, oh yeah... Exactly! I would love to hear some real-world stuff like that from those guys. Salil Khedkar [^]

            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