Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need multiple inheritance functionality in C#. What am I doing wrong?

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?

like image 434
jaybny Avatar asked Dec 22 '22 12:12

jaybny


1 Answers

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.

like image 192
Brandon Moretz Avatar answered Jan 12 '23 09:01

Brandon Moretz