class UDPClient
{
}
class LargeSimulator
{
}
class RemoteLargeSimulatorClient : UDPClient, LargeSimulator
{
}
The saying goes, if you need multiple inheritance, your design is off.
How would I get this done in C# without having to implement anything?
Unfortunately you will need to write wrapper methods to the members. Multiple inheritance in C# does not exist. You can however implement multiple interfaces.
One possible substitute for multiple inheritance is mixins. Unfortunately C# doesn't have those either, but workarounds are possible. Most rely on the use of extension methods (as a previous answerer suggested). See the following links:
http://mortslikeus.blogspot.com/2008/01/emulating-mixins-with-c.html http://www.zorched.net/2008/01/03/implementing-mixins-with-c-extension-methods/ http://colinmackay.co.uk/blog/2008/02/24/mixins-in-c-30/
You can only inherent from a single base class in C#. However, you can implement as many Interfaces as you'd like. Combine this fact with the advent of Extension Methods and you have a (hacky) work-around.
C# only allows single inheritance, though you can inherit from as many interfaces as you wish.
You could pick just one class to inherit from, and make the rest interfaces, or just make them all interfaces.
You could also chain your inheritence like so:
To get multiple inheritance the way you want it, you need to make your UDPClient and LargeSimulator
interface
instead ofclass
.Class multiple inheritance isn't possible in C#
The short answer: Multiple inheritance is not allowed in C#. Read up on interfaces: http://msdn.microsoft.com/en-us/library/ms173156.aspx
The slightly longer answer: Maybe some other design pattern would suit you, like the strategy pattern, etc. Inheritance isn't the only way to achieve code reuse.