You are searching about When A Class Is Based On Another Class It Inherits, today we will share with you article about When A Class Is Based On Another Class It Inherits was compiled and edited by our team from many sources on the internet. Hope this article on the topic When A Class Is Based On Another Class It Inherits is useful to you.
Page Contents
.NET :Solving the Multiple Inheritance Issue Under .NET Platform
The .NET platform does not support multiple inheritance. Do not confuse multilevel inheritance with multiple inheritance. With multiple inheritance you can have a subclass that inherits from two classes at the same time.
Suppose we have an application that has a Customer and another class Vendor. If you want to combine these two classes into one CustomerVendor class, it will be a combination of Customer and Vendor as shown below.
Please copy the following URL into your browser to view the diagram: [http://www.vbprofs.com/images/Article] Image/ThomasArt1.gif
In the above picture we see how the Customer Seller class inherits from both these classes.
Multiple inheritance is complex and can be dangerous. Whether the benefits of code re-use prevail over complexity depends on your choice.
Multiple inheritance is not supported by VB.NET or the .Net platform. Instead of multiple inheritance we can use multiple interfaces to achieve the same effect of multiple inheritance.
All objects in VB.NET have a primary or basic interface, which is composed of properties, events, methods, or member variables declared using the public keyword.
Objects can also implement secondary interfaces using the implement keyword.
Sometimes it is useful for an object to have more than one interface, which allows us to interact with the object in different ways. Inheritance allows us to create subclasses that are specialized cases of the base class.
Example
Sometimes we have a group of objects that are not identical, but we want to treat them in the same way. We want all objects to behave as if they are the same, even though they are different.
We may have a few different objects in the application, like customers, products, invoices, etc. Each object will have the appropriate default interface for each object, and each of them is a separate class. No natural inheritance is implied in these classes.
Suppose we want to print a document for each type of object. In this case we want them all to act as printable objects.
To accomplish this we can define a common interface that will enable the creation of printed documents.
By implementing a common interface we can write a routine that accepts any object that implements a printed document.
To conclude, by implementing multiple interfaces in VB.NET, we can achieve the same effect as multiple inheritance.
Video about When A Class Is Based On Another Class It Inherits
You can see more content about When A Class Is Based On Another Class It Inherits on our youtube channel: Click Here
Question about When A Class Is Based On Another Class It Inherits
If you have any questions about When A Class Is Based On Another Class It Inherits, please let us know, all your questions or suggestions will help us improve in the following articles!
The article When A Class Is Based On Another Class It Inherits was compiled by me and my team from many sources. If you find the article When A Class Is Based On Another Class It Inherits helpful to you, please support the team Like or Share!
Rate Articles When A Class Is Based On Another Class It Inherits
Rate: 4-5 stars
Ratings: 9131
Views: 51681929
Search keywords When A Class Is Based On Another Class It Inherits
When A Class Is Based On Another Class It Inherits
way When A Class Is Based On Another Class It Inherits
tutorial When A Class Is Based On Another Class It Inherits
When A Class Is Based On Another Class It Inherits free
#NET #Solving #Multiple #Inheritance #Issue #NET #Platform
Source: https://ezinearticles.com/?.NET-:Solving-the-Multiple-Inheritance-Issue-Under-.NET-Platform&id=67392