Simulating Multiple Inheritance by Delegation
page 3 of 5
by Joseph Chahine
Feedback
Average Rating: 
Views (Total / Last 10 Days): 26323/ 50

When would you need it?

A simple example would be to consider that we are building a distributed application and we have a class called MyCustomCollection that inherits from System.Collections.ArrayList. We want to have instances of the MyCustomCollection class marshalled from a server to another across a firewall. In .NET, we have to derive MyCustomCollection from the MarshalByRefObject class, but is not MyCustomCollection a subclass of System.Collections.ArrayList already?! Unfortunately, we will not be able to derive MyCustomCollection from MarshalByRefObject because it can only inherit from one class, which is System.Collections.ArrayList.

In such cases, Multiple Inheritance could be helpful. Please note that there is no situation where multiple inheritance is necessary. Everything done with C++ can still be done with VB.NET or C#.NET. In this article I am just offering a workaround.


View Entire Article

User Comments

No comments posted yet.






Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-04-24 1:30:58 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search