所以我无法读取通过 Tcp 流发送的字符串。我正在使用此代码发送。
byte[] bytes = ASCIIEncoding.ASCII.GetBytes("connect");
NetworkStream stream = client.GetStream();
StreamWriter writer = new StreamWriter(stream);
writer.Write(bytes);
writer.Close();
这段代码要阅读:
public void getConnectionString()
{
NetworkStream ns = client.GetStream();
byte[] bytes = new byte[client.ReceiveBufferSize];
ns.Read(bytes, 0, bytes.Length);
string info = Encoding.ASCII.GetString(bytes);
MessageBox.Show(info);
}
但这一切返回的是 System: byte[]
它不应该返回字符串吗?我究竟做错了什么?