Split C# Interface in two?

Hi all!
I have a class I’m maintaining and I’d like to split it in two whilst retaining functionality as a whole.
To best explain this, the following oversimplified code is in order:

public class NetworkOperations
{
	public void ConnectToServer()
	{
		/// Implementation
	}

	public void ServerTearDown()
	{
		/// Implementation
	}

	public void SendData()
	{
		/// Implementation
	}
}

public class ServerNetworkOperations
{
	private NetworkOperations internalOperations;

	public void ServerTearDown()
	{
		internalOperations.ServerTearDown();
	}
	
	public void SendData()
	{
		internalOperations.SendData();
	}
}

public class ClientNetworkOperations
{
	private NetworkOperations internalOperations;
	
	public void ConnectToServer()
	{
		internalOperations.ConnectToServer();
	}
	
	public void SendData()
	{
		internalOperations.SendData();
	}
}

As we can see, I’m intending to split the interface while still keeping the implementation together via instance of internalOperations. This is to avoid duplicate implementations of “SendData()” since the code is the same.
The problem here is that anyone can “cheat” by simply instantiating the NetworkOperations class and using it directly.
However, if I make NetworkOperations private, I no longer have access to the methods I am wrapping in the other classes.
I think a Design Pattern like the Proxy will help here, but I’m sort of drawing a blank.
Seems like an easy answer, but it’s just loaded with caveats for me.

Any suggestions?

Make NetworkOperation the top class of the two other and make the methods you want to be accessible from those classes protected so they are not accessible outside:

public abstract class NetworkOperations
{
    protected void ConnectToServer()
    {
       /// Implementation
    }
 
    protected void ServerTearDown()
    {
       /// Implementation
    }
 
    protected void SendData()
    {
       /// Implementation
    }
}

public class ServerNetworkOperations:NetworkOperations
{
 
    public new void ServerTearDown()
    {
        base.ServerTearDown();
    }
 
    public new void SendData()
    {
       base.SendData();
    }
}
 
public class ClientNetworkOperations:NetworkOperations
{
    public new void ConnectToServer()
    {
       base.ConnectToServer();
    }
 
    public new void SendData()
    {
       base.SendData();
    }
}

Your sub classes inherits the protected method but since you want the method in the sub classes to be public (I guess so) you would have to change the access modifier and then you get a warning the you are hiding the inheriting methods. Add the new keyword to remove the warning and call the base method.

EDIT: the top class becomes abstract to avoid instance of it.

If you don’t plan on having the NetworkOperations instatiated at any point you can make it abstract. An abstract method can not be instatiated itself, only trough inheritance.
Make the methods you are planning on overriding virtual and using override keyword to override them. When you inherit from a class and don’t need to change that actual implementation of the method, you can just call it without overriding it.
This is how I would have done it.

`

public abstract class NetworkOperations
{
    public virtual void ConnectToServer()
    {
        // implementation
    }

    public virtual void ServerTearDown()
    {
        // implementation
    }

    public virtual void SendData()
    {
        // implementation
    }
}

public class ServerNetworkOperations : NetworkOperations
{

}

public class ClientNetworkOperations : NetworkOperations
{

}

`