Article Categories
» Arts & Entertainment
» Automotive
» Business
» Careers & Jobs
» Education & Reference
» Finance
» Food & Drink
» Health & Fitness
» Home & Family
» Internet & Online Businesses
» Miscellaneous
» Self Improvement
» Shopping
» Society & News
» Sports & Recreation
» Technology
» Travel & Leisure
» Writing & Speaking

  Listed Article

  Category: Articles » Technology » Computers » Article
 

.NET : Solving The Multiple Inheritance Issue Under .NET Platform




By Thomas Kaloyani

.NET platform does not support multiple inheritance. Do not confuse multilevel inheritance with multiple inheritance. With multiple inheritance we can have a subclass that inherits from two classes at the same time.

Let's suppose we have an application that has a class Customers and another class Vendors. If you wanted to combine these two classes into one CustomerVendor class it would be a combination of Customers and Vendors just like the diagram below.

Please copy the following link into a new browser windor to view the diagram: http://www.vbprofs.com/images/Article Images/VBNETinheritance.gif

In the above diagram we see how the CustomerVendor class inherits from both of those classes.

Multiple inheritance is complex and can be dangerous. The advantages of code re-usage prevail over complexity is up to your choice.

Multiple inheritance is not supported by VB.NET or .Net platform. Instead of multiple inheritance we can use multiple interfaces to achieve similar effect to multiple inheritance.

In VB.NET all objects have a primary or native interface, which is composed of properties, events, methods or member variables declared using Public keyword. Objects can implement also secondary interfaces by using Implement keyword.

Sometimes it is helpful for an object to have more than one interface, allowing us to interact with the object in different ways. Inheritance allow us to create subclasses that are a specialized case of the base class.

Example

Sometimes we have a group of objects that are not the similar, but we want to handle them the same manner. We want all the objects to act as if they are the same, even though they are different.

We can have some different objects in an application, such as customer, product, invoice etc. Each object would have a default interface appropriate to each individual object, and each of them is a different class. No natural inheritance is implied between these classes.

Let's suppose we want to print a document for each type of object. In this case we'd like to make them all act as printable object. To accomplish this we can define a generic interface that would enable generating a printed document. By implementing a common interface we are able to write a routine that accepts any object that implements a printed document.

To conclude, by implementing multiple interfaces in VB.NET, we can achieve a similar effect to that of multiple inheritance.
 
 
About the Author
Thomas is an experienced Visual Basic developer, with expertise of 7 years developing financial applications. His main IT skills are VB, SQL, Crystal Reports - should you need a VB developer for your projects feel free to contact Thomas through his personal website at http://www.Kaloyani.com or through http://www.VBprofs.com

Article Source: http://www.simplysearch4it.com/article/9275.html
 
If you wish to add the above article to your website or newsletters then please include the "Article Source: http://www.simplysearch4it.com/article/9275.html" as shown above and make it hyperlinked.



  
  Recent Articles
Microsoft Word. The power is under the hood
by Robert Duval

How To Select The Best Gaming Laptops
by Tim Childree

How To Select The Best Business Laptops
by Tim Childree

High-Tech Computer Rental for Business Promotion
by Michael Braganza

Managing a Worldwide Print Infrastructure from a Single Workstation in a Central Location
by Rick Ferguson

A Sneak Peek Into The World Of Refurbished Laptops
by Javier Fuller

Battery information
by goodbattery

Tell Me About Computers
by Khal Nuwar

Setting Up Your Own Internet Radio Station
by Jason Cole

Understanding Solar Energy
by Anna Stone

Mac FAXstf X Pro Faxing Program for Mac OS X Users
by Nivea David

How to Retrofit a Picture or an Image into Desktop Wallpaper for Your Computer
by Steve Dimeck

Wallpaper Choosing For Good Mood
by Dalvin Rumsey

Software Discounts
by Joe Cohen

Mac:The computer of new age
by Harry Johnson

Apple new iMac line with Intel core 2 Duo
by Monica Craft

Grid Computing
by Sandro Azzopardi

Guide to Buying a Webcam
by Andrew Gates

Can't connect to database