UdpClient 如何发送结构体

.Net技术 码拜 9年前 (2014-12-13) 1775次浏览 0个评论
 public struct codinate
        {
            public int x;
            public int y;
        }
            codinate a;
            a.x = 10;
            a.y = 20;//如何将a这个结构体发送过去呢?

          UdpClient udpsender = new UdpClient();
            IPEndPoint ipend = new IPEndPoint(IPAddress.Parse("192.168.1.255"), 6000);
            string message = "ok";
            byte[] bytes = Encoding.ASCII.GetBytes(message);
            udpsender.Send(bytes, bytes.Length, ipend);
            udpsender.Close();

可以给出具体代码吗?


CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明UdpClient 如何发送结构体
喜欢 (0)
[1034331897@qq.com]
分享 (0)

文章评论已关闭!