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.
Nicole Calinoiu commented
@Joshua Schaeffer: Multiple inheritance isn't the only way to skin that particular cat. Better language and/or framework support for composition (e.g.: http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/2099133-add-auto-implement-feature-to-c-language) would enable such scenarios without the potential pitfalls of multiple inheritance.
Joshua A. Schaeffer commented
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.
[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...
Don't do that.
Francis Rodgers commented
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 Brightons commented
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++.
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.
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.
Since the CLR doesn't support multiple inheritance and probably never will, traits make more sense, since they are added on top of single-inheritance and don't need CLR support AFAIK: http://en.wikipedia.org/wiki/Trait_(computer_programming)
DoubleFloat (Dominik Mönks) commented
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.
Multiple inheritance was not added in first C# and I think will not be added in later versions. You can try to google "why multiple inheritance is evil" or read this
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.
Multiple inheritance is deemed evil, but mixins could be handy.
Nicole Calinoiu commented
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.