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

后端 未结 6 1928
野性不改
野性不改 2021-01-19 09:08
class UDPClient
{
}

class LargeSimulator
{
}

class RemoteLargeSimulatorClient : UDPClient, LargeSimulator
{
}

The saying goes, if you need multip

6条回答
  •  时光取名叫无心
    2021-01-19 09:35

    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:

    class UDPClient
    {
    }
    
    class LargeSimulator : UDPClient
    {
    }
    
    class RemoteLargeSimulatorClient : LargeSimulator
    {
    }
    

提交回复
热议问题