When A Class Is Based On Another Class It Inherits .NET :Solving the Multiple Inheritance Issue Under .NET Platform

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.

.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

Related Posts

default-image-feature

What When Where Who Why How Exercises Pdf P90x Workout Schedule PDF

You are searching about What When Where Who Why How Exercises Pdf, today we will share with you article about What When Where Who Why How Exercises…

default-image-feature

What To Wear When You Have Nothing To Wear Clothing and Women’s Clothing – The Ideal Shopper

You are searching about What To Wear When You Have Nothing To Wear, today we will share with you article about What To Wear When You Have…

default-image-feature

What To Say To A Family When Someone Dies Tips for Writing a Sympathy Message

You are searching about What To Say To A Family When Someone Dies, today we will share with you article about What To Say To A Family…

default-image-feature

What To Look For When Joining A Gym Gym Dinosaurs Face Extinction – An Alternative Look at the Fitness Industry

You are searching about What To Look For When Joining A Gym, today we will share with you article about What To Look For When Joining A…

default-image-feature

What To Do When Your Facebook Page Is Hacked Facebook Fan Pages: Dangers and Threats

You are searching about What To Do When Your Facebook Page Is Hacked, today we will share with you article about What To Do When Your Facebook…

default-image-feature

What Is Your Objective When You Are Writing To Persuade Persuasive Essay Topics – How to Come Up With Persuasive Topics For Your Readers

You are searching about What Is Your Objective When You Are Writing To Persuade, today we will share with you article about What Is Your Objective When…