【问题标题】:Client connect server c# network客户端连接服务器c#网络
【发布时间】:2013-06-13 22:00:56
【问题描述】:
IPAddress ip = new IPAddress(new byte[] (127,0,0,0));
TcpClient con = new TcpClient ();
con.Connect(ip,5020);
byte[] dtabfr;
dtabfr = Encoding.ASCII.GetBytes(textBox1.Text);
NetworkStream strm =con.GetStream();
strm.Write(dtabfr,0,dtabfr.Length);
strm.Close();
con.Close();

Error IPAddress ip Array creation must have array size or array initializer

【问题讨论】:

    标签: c# network-programming


    【解决方案1】:

    试试

     IPAddress ip = new IPAddress(new byte[]{127,0,0,0});
    

    或者干脆做

    var ip = IpAddress.Parse("127.0.0.0");
    

    【讨论】: