我需要一个类,将有一切的TcpClient有+一对额外的领域,所以我创建了一个基于TcpClient的一类:AcceptTcpClient()和阶级基础的TcpClient
public class MyClient: TcpClient
{
public string winUser;
public bool needHelp;
public bool needSignOff;
public MyClient() : base() {
this.needHelp = false;
this.needSignOff = false;
this.winUser = "empty";
}
}
现在我需要所有传入连接是
MyClient clientConnection = (MyClient)this.helpServer.AcceptTcpClient();
的问题是,AcceptTcpClient()产生的TcpClient类对象,我不断收到此异常,当我尝试连接到服务器:
为这个类的对象创建listenServer():无法强制类型为“System.Net.Sockets.TcpClient”的对象键入“Server.MyClient”。
如何将AcceptTcpClient()提供给我的TcpClient对象转换为MyClient对象?
这是根本不可能的。 – SLaks