I suggest you ...

Allow multiple inheritance from classes

If you inherit from a class in the framework or another third party library it would be great, if I could add stateful methods and properties - not extension methods. The easiest way would be multi inheritance. C++ can do so, so C# should allow this too. To add a simple Method for logging you have to write code over and over again.

39 votes
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    AnonymousAnonymous shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

    15 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      Submitting...
      • Joshua A. SchaefferJoshua A. Schaeffer commented  ·   ·  Flag as inappropriate

        I have a simple class that implements INotifyPropertyChanged, caches PropertyChangedEventArgs instances, and exposes PropertyChanged that you want to use the += operator on. I want to be able to tack this onto any other class. Without multiple inheritance I have to duplicate this functionality every single time and maintain it separately every single spot.

        People who are against multiple inheritance tend to be simple programmers. Bleeding edge requires more.

      • aprapr commented  ·   ·  Flag as inappropriate

        [I've yet to see a convincing argument against multiple inheritance. After all arguments have been debunked people always default to "but dumb programmers will abuse it!"]

        Totally agree. This is a must have feature.

        Multiple iheritance, goto, eval(), pointers and so on is only evil for who doesn't understand it...

      • Francis RodgersFrancis Rodgers commented  ·   ·  Flag as inappropriate

        I agree. Implement it as programmers we should be given the choice of usage. Anyone good enough to use multiple inheritance or one or more of its alternates, has enough knowledge to use it wisely or will learn how to in good time. Anyway, many companies will have their own programming policies which may or may not prevent or require programmers to use it or not. But esentially, let it be up to the programmer or company instead of it being a choice made for us.

      • Rich BrightonsRich Brightons commented  ·   ·  Flag as inappropriate

        It could save an awful lot of work. While there are many wonderful things about C#, for me I particularly like the static typing, the power of its its type system is still weak compared with Smalltalk and Lisp, both of which are much older languages. Bertrand Meyer is a great example of someone who values multiple inheritance but is no fan of C++.

      • AnonymousAnonymous commented  ·   ·  Flag as inappropriate

        I've yet to see a convincing argument against multiple inheritance. After all arguments have been debunked people always default to "but dumb programmers will abuse it!"

        For example, the so called diamond problem is not a problem at all if you use something called "The Compiler" (tm). It should just throw an error if there's a collision and you don't specify which implementation of the method/property you want. That's it!

        I don't see anyone complaining about the following line of code:
        var monkey = isMonkey ? "y" : "n";

        What happens if you try the following?
        var monkey = isMonkey ? 1 : "n";

        The sky is not falling, the compiler just throws an error if it can't resolve the type.

      • PhilippePhilippe commented  ·   ·  Flag as inappropriate

        I would hightly recommand you to uses interface instead and for code sharing purpose create a class with static functions that you call from the implementation of your interface.

        Multiple inheritances can easily lead to bas design that is hard to maintain. I haven't used multiple inheritance since at least 10 years and have no regrets.

      • DoubleFloat (Dominik Mönks)DoubleFloat (Dominik Mönks) commented  ·   ·  Flag as inappropriate

        I just read about how other languages solve this problem after following your link and I think the way Python implements it is pretty intuitive.
        Why should there be no such feature in C#? The risks of managing redundant code in multiple classes is far higher than the risks of encountering exceptions, at least in my opinion.
        I could understand if people don't want this to be supported in Basic, as it is usually used to get comfortable with programming basics, but C# is more "professional" in some way. Professionals should be able to handle this feature and resolve problems when encountering them. Also, nobody would be forced to us it.

      • tftf commented  ·   ·  Flag as inappropriate

        For the current comments: If something is available, it does not mean you have to use it!
        And if we do not allow anything in the languages that can be misused, we better stop programming.

        Multiple inheritance has a really big power - it is the one big missing OO part in VB and C#, so please add it to the languages.

        It will not be used much, but in the cases it is needed, it saves a lot of work.

      • MaxMax commented  ·   ·  Flag as inappropriate

        Multiple inheritance is deemed evil, but mixins could be handy.

      • Nicole CalinoiuNicole Calinoiu commented  ·   ·  Flag as inappropriate

        I'm with Anonymous. If you're looking to support scenarios like this, providing a post-compiler for AOP support would be much more useful.

      Feedback and Knowledge Base