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#net doesnot support Mul.inheritance?

WHy C#net doesnot support Mul.inheritance?

Scheduled Pinned Locked Moved C#
csharpoopquestion
10 Posts 6 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.
  • A Offline
    A Offline
    Ali_100
    wrote on last edited by
    #1

    Why C#.net does not support multiple inheritance?why it can support by interface?why not by class?

    P U N 3 Replies Last reply
    0
    • A Ali_100

      Why C#.net does not support multiple inheritance?why it can support by interface?why not by class?

      P Offline
      P Offline
      PIEBALDconsult
      wrote on last edited by
      #2

      Because the designers decided they'd cripple the language in the interests of making it "safer". X| Implementing an interface is unrelated to inheritence.

      1 Reply Last reply
      0
      • A Ali_100

        Why C#.net does not support multiple inheritance?why it can support by interface?why not by class?

        U Offline
        U Offline
        Uri Lavi
        wrote on last edited by
        #3

        C# and Java languages don't support multiple inheritance because of the diamond problem[^]. Here is the short summary:

        The diamond problem is an ambiguity that arises when two classes B and C inherit from A, and class D inherits from both B and C. If a method in D calls a method defined in A (and does not override the method), and B and C have overridden that method differently, then from which class does it inherit: B, or C?

        Uri

        C P 2 Replies Last reply
        0
        • U Uri Lavi

          C# and Java languages don't support multiple inheritance because of the diamond problem[^]. Here is the short summary:

          The diamond problem is an ambiguity that arises when two classes B and C inherit from A, and class D inherits from both B and C. If a method in D calls a method defined in A (and does not override the method), and B and C have overridden that method differently, then from which class does it inherit: B, or C?

          Uri

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          This is a stupid example, given by people too stupid to understand the value of multiple inheritance. It seems the C# team is in general too stupid to understand complex solutions, I asked them for default parameter values years ago, and they got very confused trying to work out how that would work, or why you'd use it. The example is valid, but it assumes the programmer is a moron. A good language assumes it will be used well, not protects itself from being used poorly

          Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

          P S 2 Replies Last reply
          0
          • C Christian Graus

            This is a stupid example, given by people too stupid to understand the value of multiple inheritance. It seems the C# team is in general too stupid to understand complex solutions, I asked them for default parameter values years ago, and they got very confused trying to work out how that would work, or why you'd use it. The example is valid, but it assumes the programmer is a moron. A good language assumes it will be used well, not protects itself from being used poorly

            Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

            P Offline
            P Offline
            PIEBALDconsult
            wrote on last edited by
            #5

            Hear hear! I think that's what I said. :-D

            Christian Graus wrote:

            default parameter values

            Aren't those in C# 4.0 ?

            C 1 Reply Last reply
            0
            • P PIEBALDconsult

              Hear hear! I think that's what I said. :-D

              Christian Graus wrote:

              default parameter values

              Aren't those in C# 4.0 ?

              C Offline
              C Offline
              Christian Graus
              wrote on last edited by
              #6

              Yes, you did.

              PIEBALDconsult wrote:

              Aren't those in C# 4.0 ?

              Yes, it's taken them three iterations to realise the people crying for it were right. And, they explicitly told me that if they have a choice between making the language powerful, or making it easy and safe, they choose the latter.

              Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

              1 Reply Last reply
              0
              • U Uri Lavi

                C# and Java languages don't support multiple inheritance because of the diamond problem[^]. Here is the short summary:

                The diamond problem is an ambiguity that arises when two classes B and C inherit from A, and class D inherits from both B and C. If a method in D calls a method defined in A (and does not override the method), and B and C have overridden that method differently, then from which class does it inherit: B, or C?

                Uri

                P Offline
                P Offline
                PIEBALDconsult
                wrote on last edited by
                #7

                That's no reason. Pointers are much more dangerous yet they're still available in C#. Why not allow multiple inheritence in an unsafe context? :-D

                1 Reply Last reply
                0
                • A Ali_100

                  Why C#.net does not support multiple inheritance?why it can support by interface?why not by class?

                  N Offline
                  N Offline
                  N a v a n e e t h
                  wrote on last edited by
                  #8

                  Chris Brumme from the CLR team explain here[^] the reason.

                  Navaneeth How to use google | Ask smart questions

                  P 1 Reply Last reply
                  0
                  • C Christian Graus

                    This is a stupid example, given by people too stupid to understand the value of multiple inheritance. It seems the C# team is in general too stupid to understand complex solutions, I asked them for default parameter values years ago, and they got very confused trying to work out how that would work, or why you'd use it. The example is valid, but it assumes the programmer is a moron. A good language assumes it will be used well, not protects itself from being used poorly

                    Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                    S Offline
                    S Offline
                    S Senthil Kumar
                    wrote on last edited by
                    #9

                    Christian Graus wrote:

                    It seems the C# team is in general too stupid to understand complex solutions

                    Wow, that's quite an accusation. How many programming languages have you written, Christian? I'd think the main issue here is not language, but the CLR. If C# supports multiple inheritance, there must be some way to express it in metadata and IL, which means the CLR must support it. I'm guessing here that that would mean only a language which is aware of multiple inheritance would be able to deal with that type. Also, the way C++ implements MI might not be compatible with the CLR requirements (reflection etc..), so there are problems even for a language that already supports MI. In general, I'd say language changes that only affect code generation (lambdas, automatic properties) are much more simpler than those that change the type system (generics etc..).

                    Christian Graus wrote:

                    I asked them for default parameter values years ago, and they got very confused trying to work out

                    Unlike C++ which requires recompilation whenever a module changes, .NET supports binding against different versions of a module (assembly). Which means that embedding the default values at the caller will break versioning. I don't see how that assumes the programmer is a moron.

                    Regards Senthil _____________________________ My Home Page |My Blog | My Articles | My Flickr | WinMacro

                    1 Reply Last reply
                    0
                    • N N a v a n e e t h

                      Chris Brumme from the CLR team explain here[^] the reason.

                      Navaneeth How to use google | Ask smart questions

                      P Offline
                      P Offline
                      PIEBALDconsult
                      wrote on last edited by
                      #10

                      Ah, now that makes sense! I can certainly see how technical issues can inhibit implementation; I hope they really are trying to resolve them. P.S. And mixins sound like a good idea too.

                      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