.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 want 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 URL into your browser to view the diagram: http://www.vbprofs.com/images/Article Images/ThomasArt1.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 also implement 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 allows 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 in 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.
Thomas is an experienced Visual Basic developer, with expertise of 7+ years developing especially financial applications. His main IT skills are VB, SQL, Crystal Reports - should you need a Visual Basic developer for your projects feel free to contact Thomas through his personal website Kaloyani.com or through VBprofs.com - the newest Visual Basic and VB.NET resources portal.
Article Source: http://EzineArticles.com/
Recent article: Application Software Articles
Dekart Private Disk creates one or more virtual disks on your hard drive and/or other external storage devices. Once a user creates a virtual encrypted disk, that disk is assigned a new drive letter and appears to the user like any other system drive (like the A: or C: drive). When the disk is mounted, the data is automatically encrypted and decrypted when the user writes or reads this data respectively. Dekart Private Disk encrypts and decrypts all data stored on the encrypted disk with virtually no performance penalty. When the disk is unmounted, either manually or by logging out of Windows, the secure data it contains becomes completely unreadable and undetectable by the operating system. Dekart Private Disk allows you to store your information on a host of media such as HDD, FDD, CD, CD/R, CD/RW, MO, MD, ZIP-disks, flash drives, all types of flash memory cards, PDAs, and even digital cameras. You have the flexibility to allow multiple users to share a single PC.
-
Articles Categories
- Advertising Articles
- Software Articles for Beginners
- Software Process and Project Management
- Business Solutions with Softwares
- Computer Networking and Security
- Internet Marketing
- Search Engine Optimization
- Software Utilities
- Application Software
- Software Learning
- Web Designing Articles
- Programming Articles
- PhotoShop Articles
- SE Positioning Articles
- Site Security Articles
- Technology Articles
- Traffic Analysis Articles
- Multimedias Articles
- Education Articles
- Link Popularity Articles
- Online Promotion Articles
- Content Writing Articles
- LinkBuilding Articles
- Webmasters Articles
- E-Bussiness Articles
- Careers Articles
- Computers Articles
- Copywriting Articles
- HTML Articles
- CSS Articles
- DHTML Articles
- Javascript Articles
- RSS Articles
All Information about Interview. Tips and Guideline. www.interviewGHOST.com
What Users Asked:
Advertisement Area :