Well, I’m trying to reuse a portion of C# code. It’s an abstract class with UDP server, which can be seen here:
http://clutch-inc.com/blog/?p=4
I’ve created a derived class like this:
public class TheServer : UDPServer
{
protected override void PacketReceived(UDPPacketBuffer buffer)
{
}
protected override void PacketSent(UDPPacketBuffer buffer, int bytesSent)
{
}
}
And in my app I’ve created an instance of the derived class like this:
TheServer serv = new TheServer(20501);
serv.Start();
But I’ve got errors and I don’t really understand why. Please help.
- ‘TheProject.TheServer’ does not
contain a constructor that takes ‘1’
arguments - ‘TheProject.UDPServer.Start()’ is
inaccessible due to its protection
level - ‘TheProject.UDPServer’ does
not contain a constructor that takes
‘0’ arguments
Constructors do not get inherited in C#. You will have to chain them manually:
Also, if Start is protected, you will have to create some sort of public method that calls it: