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.
Constructors do not get inherited in C#. You will have to chain them manually:
public TheServer(int port)
: base(port)
{
}
Also, if Start is protected, you will have to create some sort of public method that calls it:
public void StartServer()
{
Start();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With