class User
{
public readonly TcpClient client;
public readonly StreamReader sr;
public readonly StreamWriter sw;
public string userName;
public User(TcpClient client)
{
this.client = client;
this.userName = "";
NetworkStream netStream = client.GetStream();
sr = new StreamReader(netStream, System.Text.Encoding.UTF8);
sw = new StreamWriter(netStream, System.Text.Encoding.UTF8);
}
}代码都贴在这里了,我的理解是累类的构造函数重载对这个类的变量初始化,但是不清楚this.client = client;这一句应该怎么理解。请各位高手指点一下啊,谢谢!
{
public readonly TcpClient client;
public readonly StreamReader sr;
public readonly StreamWriter sw;
public string userName;
public User(TcpClient client)
{
this.client = client;
this.userName = "";
NetworkStream netStream = client.GetStream();
sr = new StreamReader(netStream, System.Text.Encoding.UTF8);
sw = new StreamWriter(netStream, System.Text.Encoding.UTF8);
}
}代码都贴在这里了,我的理解是累类的构造函数重载对这个类的变量初始化,但是不清楚this.client = client;这一句应该怎么理解。请各位高手指点一下啊,谢谢!
this.client是这个类中的定义的public readonly TcpClient client; , 而client,是构造函数传进来的参数,很基础哦..
用来初始化User对象的client啊