Why multiple Inheritence is not used in C#?
Answers were Sorted based on User's Feedback
Answer / naveen mishra
We can implement multiple Inheritence using interfaces
Is This Answer Correct ? | 15 Yes | 3 No |
Answer / a b
Implementing from multiple interfaces is not true multiple
inheritance. The objective of inheritance is code reuse,
which is attained only when the base class contains that
code. But since an interface does not contain any code code
at all, there's no code reuse happening at all. Instead, an
implementing class needs to provide code for each and every
method defined in a class.
Is This Answer Correct ? | 3 Yes | 0 No |
Answer / a b
Sorry just a correction in 5 above, please read the last
line as 'Instead, an implementing class needs to provide
code for each and every method defined in an interface.'
Is This Answer Correct ? | 3 Yes | 0 No |
Answer / mayur teli
There is the classic diamond problem encountered in multiple inheritance, in which class D inherits from both B and C, which both inherit from A.
A
/ \
B C
\ /
D
So which copy of A does D get? The one from B, the one from C? Both? This way various languages resolve this problems is discussed here:
http://en.wikipedia.org/wiki/Diamond_problem
Is This Answer Correct ? | 3 Yes | 0 No |
Answer / ashwi ni chavan
A
/ \
B C
\ /
D
here D get the 2 copy's of A first copy get from B then
second copy get from C .
In class D name collision problem occure means two method's
or data member has same name occure in D class.thats why get
confusion of that's method's this promblem is also called as
Diamond problem........this problem solved using the
interface concept .
Is This Answer Correct ? | 0 Yes | 0 No |
Is it possible to restrict the scope of a field/method of a class to the classes in the same namespace?
What is the use of thread join in c#?
How many bytes is a char c#?
Is typeof c#?
What is the diff between System.String and System.Text.StringBuilder classes?
Explain hash table in c# ?
write code for inserting and updating recoards in sql server database using connected architecture & records shoulds displayed in grid view ( use c# )
What is difference between const and static in c#?
What is the difference between new and override in c#?
what is webapplication? what is windows application? what is the extension for both . in what purpose we r using webapplication. in which situation we r using windowns application
What is an expression in c#?
Explain the 3 types of properties in c# with an example?