Jan 16, 2020

Why multiple inheritance not support through class and support through interface

multiple inheritance in c#,c# inheritance,classes multiple inheritance
multiple inheritance does not support through classes

Why multiple inheritance not support through class and support through interface

            Before the explanation you should know all the points about multiple inheritances.         
The multiple inheritances is not support through class, look why we use inheritance to class to consume the member of a class to another where two class may have same name and signature like this
multiple inheritance, multiple inheritance through class, inheritance through classes,class in c#, inheritance
multiple inheritance support through interfaces not through class

When we call the Demo () method then here the ambiguity rise which Demo () method should call that’s why multiple inheritance is not supported through class.
            Where in case of interfaces contain only abstract members and we are going to inherit the interfaces not for consuming the member but for the implementation of the members. In this case we can built or perform multiple inheritance because we are going to implement the abstract member or method. Hera also the interface can contain multiple methods of same name and signature like
multiple inheritance, multiple inheritance through interfaces, inheritance through interface,interface
multiple inheritance support through interfaces not through class-
But when the word come to implementation there is no chance of raise ambiguity because we are not consuming any method we are just implementing the method and ambiguity is not raise for implementation that’s why multiple inheritance support  through interface but not by class.

Performing multiple inheritance process

            We will see three cases in this topic
Case 1:
When we have multiple class in our program and zero interface in the case we only able to perform single or multi-level inheritance not chance to perform multiple inheritance.
class inheritance, multiple inheritance, inheritance,class,
why classes not support multiple inheritance 
Case 2:
            Case two state if we have multiple interfaces and zero class in this case we can perform multiple inheritance as want. Also can perform single and multi-level inheritance like this  
interfaces inheritance,inheritance,interface in c#
why interface support multiple inheritance
Case 3:
        Case 3 deals if we have class as well as interface then the possibilities will be. We can use only one class and set of interfaces when building inheritance like, 
multiple inheritance support by interface inc#,multiple inheritance does not support by class
multiple inheritance is not support through classes but support through interfaces
Or we can skip the class and use multiple interfaces, but in this case also you can use only one class and multiple interfaces at a time. 
In simple words we perform inheritance between the classes to consuming the members and  inheritance perform to interfaces to implementation, where while consuming ambiguity problem can raise and no problem when implementing that’s why multiple inheritance is not support through class but still support through interfaces in c#/ CSharp.




0 comments:

Post a Comment

Please do not enter any spam link in the comment box